Java Utililty Methods JFrame

List of utility methods to do JFrame

Description

The list of methods to do JFrame are organized into topic(s).

Method

voidabrirJFrameCentralizado(JFrame dialog)
abrir J Frame Centralizado
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
voidactivateWindowClosingButton(JFrame frame)
activate Window Closing Button
frame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent evnt) {
        evnt.getWindow().setVisible(false);
        evnt.getWindow().dispose();
});
voidaddDisposeActionWithEscapeKey(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();
};
...
voidaddEscapeExitListeners(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);
});
...
voidaddEscapeListener(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);
...
voidaddJFrameReporter(JFrame to)
add J Frame Reporter
guireporter = new JTextArea();
to.add(guireporter);
voidaddPanelToFrame(final JFrame frame, final JPanel panel, final String title)
Adds the panel to frame.
frame.add(panel);
frame.setTitle(title);
frame.applyComponentOrientation(getDefaultComponentOrientation());
JProgressBaraddProgressBar(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;
...
voidaddToQue(JFrame frame)
add To Que
reaktivationQue.add(frame);
File[]allPlatformGetFile(String dialogTitle, File locationIn, final String fileExtension, FileFilter nonMacFileFilter, boolean allowMultipleSelect, JFrame parentFrame)
all Platform Get File
File location = locationIn;
if (location == null) {
    location = new File("default location");
File[] returnFile = new File[] { null };
JFileChooser fc = new JFileChooser(location);
fc.setDialogType(JFileChooser.OPEN_DIALOG);
fc.addChoosableFileFilter(nonMacFileFilter);
...