Solved

jtree - one liner

Posted on 2001-06-14
3
224 Views
Last Modified: 2010-03-31
How do I start a tree view with certain branches expanded using getTreeCellRendererComponent?
0
Comment
Question by:menubar
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Igor Bazarny earned 50 total points
ID: 6193017
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
 

Author Comment

by:menubar
ID: 6195475
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
 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6196780
Oops. Did you submiit a new question? I planned to play with JTree a bit and help you with your real problem.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now