The list of methods to do JFrame are organized into topic(s).
void
activateWindowClosingButton(JFrame frame) activate Window Closing Button
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evnt) {
evnt.getWindow().setVisible(false);
evnt.getWindow().dispose();
});
void
addDisposeActionWithEscapeKey(final JFrame frame) Adds the dispose action with escape key.
KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
Action disposeAction = new AbstractAction() {
private static final long serialVersionUID = 0L;
@Override
public void actionPerformed(ActionEvent e) {
frame.dispose();
};
...
void
addEscapeExitListeners(final JFrame window) add Escape Exit Listeners
addKeyAdapterRecursively(window, new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
System.exit(0);
});
...
void
addEscapeListener(final JFrame frame) add Escape Listener
final ActionListener escListener = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
frame.dispose();
};
frame.getRootPane().registerKeyboardAction(escListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
...
JProgressBar
addProgressBar(final JFrame win) add Progress Bar
JProgressBar progressBar = new JProgressBar(0, 1);
JPanel newRoot = new JPanel();
newRoot.setLayout(new BoxLayout(newRoot, BoxLayout.Y_AXIS));
newRoot.add(win.getContentPane());
newRoot.add(progressBar);
win.setContentPane(newRoot);
win.pack();
return progressBar;
...