Hi, i want to have several different icons for a JTree at the same time.
Currently i have a GUI that creates a JTree that has a folder as the root, and a list of files/subfolders under it - (root is based on user input)
Anyhow, i want different files to have different icons. Such as a different Icon for .txt files and another for .doc files.
I have look on the tutorials, but it mostly talks about 1 icon for all leaf nodes, and a different for directories.
Will i have to change my current tree type to do this? i just have a JTree. Is there some kind of mutableJTree? i couldnt find one.
I wish i could just do something like:
for(int row =0; row <MyTree.getRowCount(); row++)
{
String s = MyTree.getNodeName(row);
File f = new File(s);
if( hasSomeDefinedProperty(f) )
{
MyTree.getNode(row).setIcon( myIcon );
}
}
public boolean hasSomeDefinedProperty(File f)
{
// check for some property, such as file type, or a certain string in the File.
}
Is there even a simple metod such as " MyTree.getNode(row).setIcon( myIcon );"
I cant even find a ".getNode(row)" method for JTree... Anyone have ideas?