File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

custom JTree icons

 
Alan Shiers
Ranch Hand
Posts: 237
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I'm trying to do a small project where I can display my own icons in a JTree. However, when I attempt to run the code below the icons don't get displayed. I've tried various combinations of code all resulting the same, no icons.
Please look over my code and tell me where I went wrong.
Thanks,
Alan

[ October 14, 2003: Message edited by: Michael Ernest ]
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll move this to the Swing forum where you're bound to get a quick response.
 
sheng wang
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you get a NullPointerException?
i think:
if you can insure images/xxx.gif in you classpath
the code is right.
 
Tamizh Selvan
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi first check whether the image is loading properly. because if the image is not loaded or if it is not the location no error is thrown. if all r ok then try the below method.
getTreeCellRendererComponent(JTree tree,
Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus)
override this method and check whether the node is leaf or closed or opened and then set the icon.
hope this helps u
Marcus
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic