Native LookAndFeel using DefaultTreeCellRenderer

Hi,

when I do the following

jTree = new javax.swing.JTree();

jTree.setCellRenderer(new DefaultTreeCellRenderer());

the tree is no longer rendered using the LAF I've specified. If I omit the setCellRenderer-line (ie. let jtree use the default renderer apparently created in the constructor), everything looks fine. How can I ensure that the cellrenderer renders things using my LAF?

[413 byte] By [va1210a] at [2007-10-1 0:05:23]
# 1

The easy answer is to not set a cell renderer and let the tree use its default as you seem to have discovered anyway. There is no need to set a renderer if you're satisfied with your tree's appearance.

That said, if you're adding complex objects to the nodes of your tree you will have to use a custom renderer (probably, unless your happy with the object's toString()).

The actual appearance of the tree, things like open/closed icons, etc. are driven by the look and feel, but can be modified as well.

Hope that helps

DB

dbulaia at 2007-7-7 15:49:29 > top of Java-index,Desktop,Core GUI APIs...