Is it possible to use custom icons for those small icons next to each node within a JTree?
I don't mean, a custom open and close folder image... I mean, each node within the entire JTree could potentially be different...
Here's my tree cell renderer (thanks CEHJ):
private class NameOnlyRenderer extends DefaultTreeCellRenderer
public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected,
boolean expanded, boolean leaf, int row, boolean hasFocus )
File f = (File ) value ;
String text = f.getName() ;
return super.getTreeCellRendererComponent( tree, text, selected, expanded, leaf, row, hasFocus ) ;
And I have a method which will return an Icon based on the file type:
public Icon getIcon( File f )
return (new JFileChooser()).getIcon( f ) ;
Can this be achieved?