Swing

Button

To set the default button for a frame:

public class Query extends javax.swing.JFrame {
    public Query() {
        initComponents();
        getRootPane().setDefaultButton(buttonOk);
    }

Exit

private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {
    System.exit(0);
}

Layout

http://www.miglayout.com/

Look and Feel

How to Set the Look and Feel

public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
    UIManager.setLookAndFeel(
            UIManager.getSystemLookAndFeelClassName());
    ...

main

Here is the correct way to instantiate your application’s UI:

public class MainFrame extends javax.swing.JFrame {

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
}

Issues

javax.swing.text.rtf.RTFEditorKit - UnsatisfiedLinkError

When using the RTFEditorKit on Debian Linux:

java.lang.UnsatisfiedLinkError:
    /usr/local/bin/j2sdk1.4.2_16/jre/lib/i386/libawt.so: libXp.so.6:
    cannot open shared object file: No such file or directory

To solve the issue (on Debian Linux):

apt-get install libxp6
apt-get install libxt6
apt-get install libxtst6