• Post Reply Bookmark Topic Watch Topic
  • New Topic

IMP: How can i change JTree editor?  RSS feed

 
Shahid Munawar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
can anyone tell me how i can change editor of
JTree, by default it is TextField....
and , can i show one leaf icon in multiple rows...
plz, reply quick,,,, its urgent.
Regards,
Shahid.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Short answer: implement the TreeCellRenderer interface (or extend DefaultTreeCellRenderer.) Your implementation of the getTreeCellRendererComponent() method should set up and return the component you want to use. Then call setCellRenderer on your JTree, passing an instance of your class.
Long answer: it's complicated, obviously, because these methods have lots of arguments and there are specific ways to do things. Sun's Java Tutorial has a nice section on JTrees. See here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!