permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes Same JTree instance across 2 tabs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Same JTree instance across 2 tabs" Watch "Same JTree instance across 2 tabs" New topic
Author

Same JTree instance across 2 tabs

Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
Hi,
I have a JTree being shown in a JTabbedPane.
Now i need to add a new tab and have the same tree being shown over there too.
Any changes dont to the tree (add/remove nodes) should reflect in both the tabs.
But that isnt happenning now.
One view is updated,but the 2nd view remains the same.
After some minimize/maximize the view in other pane is updated.
What might be the issue??

Thanks,
Chinmay


The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Hi,

You could try calling


validate();
repaint();


on the component.


SCJP 1.4, www.gsi3d.org.uk
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I made a single TreeModel, made two JTrees from it and added one to each of two tabs in a JTabbedPane. The JTrees both seem to update automatically from the TreeModel after add/remove events on the other JTree. Here's the test code I made up to explore this:
 
 
subject: Same JTree instance across 2 tabs
 
Similar Threads
Updating a JTree
JTree
JTree: How to update nodes?
JTree
JTree not updating