?
Solved

jtree - one liner

Posted on 2001-06-14
3
Medium Priority
?
281 Views
Last Modified: 2010-03-31
How do I start a tree view with certain branches expanded using getTreeCellRendererComponent?
0
Comment
Question by:menubar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Igor Bazarny earned 200 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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:
Suggested Courses

777 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