4

I created an gui application in netbeans 7.2 in java. I created a JFrame there. it was set to nimbus look and feel in auto generated code. but my frame is not look like nimbus.

so I debug the code and found nimbus is not available in the array returned by getInstalledLookAndFeels().

so what should I do to install nimbus look and feel? JDK 1.6 used to compile the code.

David Kroukamp
  • 36,155
  • 13
  • 81
  • 138
lakshman
  • 2,641
  • 6
  • 37
  • 63
  • 2
    What is the minimum Java version in which the app. is supported? If it is 1.6 I suggest it would be better to get the user to upgrade to the most recent 1.6 version. Since Nimbus was introduced around 1.6.0_10, that should ensure the user JRE has Nimbus available. – Andrew Thompson Nov 01 '12 at 14:07

1 Answers1

6

Make sure your java version is greater than: JDK 6 Update 10.

See here:

Nimbus is a polished cross-platform look and feel introduced in the Java SE 6 Update 10 (6u10) release.

you can download the latest Java (7u9) and Netbeans (7.2.1) versions (bundled) here:

After that you should be good to go, dont forget to set the L&F from within Event Disptach Thread too:

    //Create UI and set L&F on EDT
    SwingUtilities.invokeLater(new Runnable( ) {
        public void run( ) {
                //set L&F
                try {
                       for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                           if ("Nimbus".equals(info.getName())) {
                                   UIManager.setLookAndFeel(info.getClassName());
                                   break;
                           }
                       }
                    } catch (Exception e) {
                    // If Nimbus is not available, you can set the GUI to another look and feel.
                     e.printStackTrace();
                    }
            //create UI and components here
        }

    });
David Kroukamp
  • 36,155
  • 13
  • 81
  • 138