How do I make JTree folder leaf to look like a folder ?

I need to make tree folder pane in my gui,The thing is that the leaf in JTree looks like black dot. How do I change the dot to look like folder ?ILAN
[177 byte] By [Ilan_Yaniva] at [2007-11-26 18:42:03]
# 1
As per this thread but use "leafIcon" http://forum.java.sun.com/thread.jspa?threadID=5137647
itchyscratchya at 2007-7-9 6:16:03 > top of Java-index,Desktop,Core GUI APIs...
# 2

I don't understand.

Here is my code:

DefaultMutableTreeNode top =

new DefaultMutableTreeNode(this.rootFolder.getName());

createNodes(top);

//Create a tree that allows one selection at a time.

tFolder = new JTree(top);

tFolder.getSelectionModel().setSelectionMode

(TreeSelectionModel.SINGLE_TREE_SELECTION);

Now, where do I add the code, and what should I write.

BTW, where can I find the code ?

Ilan_Yaniva at 2007-7-9 6:16:03 > top of Java-index,Desktop,Core GUI APIs...
# 3

Now, where do I add the code, and what should I write.

BTW, where can I find the code ?

You add the code wherever you like as long as it occurs on the event dispatch thread (EDT) and is executed before you start creating trees. The link includes a description of what to do if you are only changing the UI for one or some trees and want others to remain as default.

The code is on the thread I linked to, it's a one-liner once you've got an icon. I'm not sure what else you're asking for.

itchyscratchya at 2007-7-9 6:16:03 > top of Java-index,Desktop,Core GUI APIs...
# 4
> How do I change the dot to look like folder ?Did you read the JTree API?If you did you would find a link to the Swing tutorial titled "How to Use Trees", which has a working example of this.
camickra at 2007-7-9 6:16:03 > top of Java-index,Desktop,Core GUI APIs...
# 5
Dear friend,I read the tutorial,There is no mentioning about changing the picture of the leaf
Ilan_Yaniva at 2007-7-9 6:16:03 > top of Java-index,Desktop,Core GUI APIs...
# 6

Then you have a reading problem...

http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#display

This is the code from the tutorial:

ImageIcon leafIcon = createImageIcon("images/middle.gif");

if (leafIcon != null) {

DefaultTreeCellRenderer renderer =

new DefaultTreeCellRenderer();

renderer.setLeafIcon(leafIcon);

tree.setCellRenderer(renderer);

}

Rodney_McKaya at 2007-7-9 6:16:03 > top of Java-index,Desktop,Core GUI APIs...