Tejas Patel
Tejas Patel

Reputation: 117

Java swing application look and feel appears different in netbeans and eclipse

I am using Netbeans IDE 7.4 for developing java swing application, where in I am trying to set the look and feel to be native. While I run the application the look and feel is not that of windows (My OS is Windows 8).

I tried using eclipse for the same where in what ever look and feel I provide in code, it appears for eg: Nimbus, Window etc.

I wanted to continue developing this application in Netbeans due to its drag and drop capabilities which saves lot of time in writing GUI specific code.

Following is the code snippet which gives me windows look and feel when it is build and run from eclipse but does not give windows look and feel when build and run from Netbeans:

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        if ("Windows".equals(info.getName())) {
            try {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (UnsupportedLookAndFeelException e) {
                e.printStackTrace();
            }
            break;
        }
    }

Upvotes: 1

Views: 1240

Answers (2)

Braj
Braj

Reputation: 46841

Have your tried?

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

or

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

For other ways have a look at How to Set the Look and Feel. A lot of sample codes are mentioned there.

Upvotes: 0

Joop Eggen
Joop Eggen

Reputation: 109547

The NetBeans IDE generates code, collapased with a "[+]" in the margin - so not obvious at first glance. I believe in the start of the main method, installing a Nimbus look-and-feel. Not quite sure, but look at the code.

In every case, it seems you are doing it earlier, that the NetBeans generated code, as there is a difference. Simple do a Find in the open project for setLookAndFeel.

Upvotes: 1

Related Questions