sivabudh
sivabudh

Reputation: 32635

Java, Netbeans: How come the GUI looks different?

I'm a Java/Netbeans newbie learning how to make a GUI.

I was following this tutorial, and I noticed that the "finished" product (first picture in that link) doesn't look like the GUI built through the steps.

Why is that? I mean, when I click on the preview button, the GUI looks native (nice) as well. It's just when it's deployed that it looks all...mmm...bad. lol.

Is there a way to make the finished GUI looks native? Is it Netbeans settings or Java settings?

Note: I'm developing this on Windows.

Upvotes: 4

Views: 6577

Answers (3)

evilReiko
evilReiko

Reputation: 20473

The default "Look and Feel" is metal-like, which is good and nice for cross-platform applications.

JDK has 4 built-in "look and feel" ('til now), which are:

  • com.sun.java.swing.plaf.gtk.GTKLookAndFeel
  • javax.swing.plaf.metal.MetalLookAndFeel
  • com.sun.java.swing.plaf.windows.WindowsLookAndFeel
  • com.sun.java.swing.plaf.motif.MotifLookAndFeel

you can try any of these "look and feel"s in 1 line, example code:

UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

NOTE: invoke/call this method of changing the "look and feel" before any GUI implementation, or it may throw some exception

Upvotes: 2

Ramon
Ramon

Reputation: 8424

Use the following code to force swing to select the "system" look and feel:

String laf = UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(laf);

Upvotes: 10

JRL
JRL

Reputation: 77995

This is referred to as the "look and feel". You can use various look and feel either when launching your app or programaticaly. See this Sun tutorial for more info.

Upvotes: 1

Related Questions