adam bien's blog

The easiest way to explore Nimbus with 6u10beta (Java SE 6 update 10) 📎

Nimbus is the new, really slick, look and feel for JDK 1.6 applications. It comes with Java 6 SE update 10.

You can activate the new Look And Feel with the following line of code: UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");

It is possible as well to set up it from the command line: -Dswing.defaultlaf=com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel. However some applications (like Netbeans :-)), still have problems with the nimbus l&f.

The fastest way to create a mock-up UI I know is with the Netbeans 6.0/6.1 "Matisse" designer running on JDK 1.6_update_10. Just create a project (New Java Project), then a "JFrame Form", or "OK / Cancel Dialog Sample Form". After this step you should find a designer pane, in which you can compose the components visually. The JFrame comes already with a main-method, so you can easily start it. However it will start with the default l&f, which isn't nimbus. To correct that, just add the bold-marked line below:

   public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                NewOkCancelDialog dialog = new NewOkCancelDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

It is actually a great way to play around with the components and explore nimbus. You can create an even complex mock-up in minutes. So Drag And Drop and enjoy!