2

I am using Net-beans for developing a small desktop application. I am using a Jtree in this application. Referring to the following tutorial:

http://download.oracle.com/javase/tutorial/uiswing/components/tree.html#display

I want to customize the look and feel of my JTree to the "Java Look and Feel" (First fig from left). How should I achieve that?

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
Jame
  • 21,150
  • 37
  • 80
  • 107

3 Answers3

3

You generally don't change the look and feel of a unique component, but the look and feel of the entire application.

See the Swing tutorial for explanations.

It's perhaps possible to change the look and feel of a single component, but then the application would be inconsistent. I would never do that.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
2

This is something you should look into : Pluggable look-and-feel architecture : Swing's pluggable look-and-feel architecture allows us to provide a single component API without dictating a particular look-and-feel. The Swing toolkit provides a default set of look-and-feels; however, the API is "open" -- a design that additionally allows developers to create new look-and-feel implementations by either extending an existing look-and-feel or creating one from scratch.

And as per the suggestion of @JB Nizet , if you prefer to change the LaF of the application , this might be helpful : Look and Feel in Java

Community
  • 1
  • 1
COD3BOY
  • 11,964
  • 1
  • 38
  • 56
0

I used this change my swing app's view to windows look and feel.
As I referred from this swing docs and this property docs.
This is how we change the look and feel using command line args. java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel MyApp java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel MyApp

But, this is how we do programmatically using these below lines.
Properties properties = System.getProperties(); properties. setProperty("swing.defaultlaf","com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

guru_007
  • 473
  • 4
  • 16