• Post Reply Bookmark Topic Watch Topic
  • New Topic

Showing same JTree on two scroll panes

 
Maroun Marounn
Greenhorn
Posts: 5
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have two JTrees that I want to display the same content on them.
I set a ScrollPane to each one and wrote this code:



sourceScroll is the scroll pane of the first JTree, and targetScroll is the scroll pane of the second JTree.

If I remove the second line, I see the JTree on the sourceScroll, which is OK. But when I enter the second line, the JTree only appears on the targetScroll and the sourceScoll is grayed.

Why doesn this happen? How can I solve this problem?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

You can add a UI component only once. That is what you are observing.
Create two JTree instances, but provide the same model to both so they are in synch.
 
Maroun Marounn
Greenhorn
Posts: 5
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Welcome to the Ranch.

You can add a UI component only once. That is what you are observing.
Create two JTree instances, but provide the same model to both so they are in synch.


Thanks a lot for your reply. I solved it by doing:



Problem solved

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!