This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes problem expanding JTree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem expanding JTree" Watch "problem expanding JTree" New topic
Author

problem expanding JTree

robyn byrd
Greenhorn

Joined: Oct 26, 2005
Posts: 9
I am progammatically expanding a JTree but the last most nodes do not expand. I'm using code I found on this forum: tree.getRowCount(), tree.expandRow(i), etc. I've also tried expandPath, but the problem remains.

I'm building a tree that looks like this:
root
|
- S1
| |
| - A1
| |
| - A2
|
- S2
|
- A3
|
- A4
First I create node S1 and add to root. Then I create node A1, add to S1, then create A2 and add to A1. Tree appears expanded during these operations.
Then I create S2 and add to root. No problems. However, when I add A3 to S2, node S2 is not expanded. When I add A4 to A3, S2 remainds collapsed. Can anyone tell me what's happening and how I make all rows of the tree to be expanded when new nodes are added. I notice that tree.getRowCount() returns 3, so it doesn't seem to count rows for the 'A' nodes.
Thanks for your help.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
"getRowCount" only returns the number of visible rows.
Expanding or Collapsing All Nodes in a JTree Component
robyn byrd
Greenhorn

Joined: Oct 26, 2005
Posts: 9
Craig:
Thanks very much. That did the trick!
Robyb
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem expanding JTree