jtree - one liner

How do I start a tree view with certain branches expanded using getTreeCellRendererComponent?
menubarAsked:
Who is Participating?
 
Igor BazarnyConnect With a Mentor Commented:
Are you sure you need getTreeCellRendererComponent?
Check out JTree.expandPath() or JTree.makeVisible()

Regards
Igor Bazarny,
Brainbench MVP for Java 1
www.brainbench.com
 
0
 
menubarAuthor Commented:
Actually what I am trying to do is not to maually assign some branches expanded. Here is what I am trying to do.

A tree is embeded in a scrollPane which is in a panel which is in a splitPane inside a frame. When user resizes the frame, I want to change the font size of the tree labels accordingly.

Here is how I do it:

I override the 'update' method with the frame.
Inside the 'update' method:
When the treeCellRenderer is set (with a specified fontSize), I do the following

  panel.remove(sp);
  sp=new JScrollPane(tree);
  panel.add(sp,BorderLayout.CENTER);
  panel.revalidate();

The problem is that expanded tree will re-appear as collapsed, when the frame is resized. There is an 'expanded' parameter in getTreeCellRendererComponent, but it doesnt appear that I can use that parameter..
0
 
Igor BazarnyCommented:
Oops. Did you submiit a new question? I planned to play with JTree a bit and help you with your real problem.
0
All Courses

From novice to tech pro — start learning today.