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 ?
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.
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);
}