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!


NEW: Online Workhop Effective WebApps without Frameworks is also coming to: MUC Airport.

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Comments:

A thought for a simpler way to explore the new L&F -- does Sun still bundle demos with the JDK? I haven't tried them in ages, but I believe they had demo applets that covered Swing fairly well, with L&F selectable.

Posted by Rob Whelan on April 22, 2008 at 04:00 PM CEST #

Rob,

sure - there is SwingSet3 bundled. So you can play with a ready to use application. With matisse you can build your own and test how it "feels" from the developer perspective,

regards,

adam

Posted by Adam Bien on April 22, 2008 at 10:51 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
realworldpatterns.com
...the last 150 posts
...the last 10 comments
License