i don't know how u r managing the level one
and level two nodes.,.
if u r managing with only levels then u
can use the following code.,
public Component
getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultTreeCellRenderer treeCellRender = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; if(node.getLevel() == 1) {/// or for u r node how u identify treeCellRender.setIcon(new ImageIcon()); <><> icon or gif image u can set }
}
but if u want to change the icon in the same levels then one way is to read
the icon names from the Properties
file and try.
On every event u can check the property of the node and u can set the
necessary icon that comes from a file.
panyam
|
- JTree and DefaultTreeCellRenderer Romel Calero Ramos
- Re: JTree and DefaultTreeCellRenderer Panyam Krishna Murthy
- Re: JTree and DefaultTreeCellRenderer Panyam Krishna Murthy
- Re: JTree and DefaultTreeCellRenderer Panyam Krishna Murthy