views:

121

answers:

2

Hi all. I've been trying to Google this answer with no results. I keep on finding answers on how to make Netbeans run in a GTK skin .... this is NOT what I want.

I have a Java Swing application. I can preview it under GTK+, C/X Motif perfectly fine when I right click the JPanel Form --> Preview. However, whenever I try to run the program (build + run), the resulting GUI is a Java Swing look and feel.

How do I permanently enable GTK+ for this program?

+1  A: 

You have to set the Look and Feel according to the native look and feel.

The following code must be ran when your app starts up.

public static void setLookAndFeel() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch(Exception e) {
      System.out.println("Error setting native LAF: " + e);
    }
}
jjnguy
Thanks! Netbeans is Complaining that I don't have UIManager. What packages do I import?
Carlo del Mundo
The package is `javax.swing`.
jjnguy
@user4026 See above.
jjnguy
Wow thanks! works perfectly!
Carlo del Mundo
@user, glad to help.
jjnguy
A: 

In Projects explorer right click on project node, select Properties, go to Application -> Desktop App node, select desired Look & Feel

Mchl
Hi. Thanks for the response! I'm using Netbeans 6.9 on a Linux Platform and I can't seem to find the Desktop App Node. Under Applications-> Desktop (I only see Web Start and Formatting).Are you on a different flavor?
Carlo del Mundo
This might be available only for Netbeans Platform applications
Mchl