jQuery in Action, 2nd edition*
The moose likes Swing / AWT / SWT and the fly likes I can't change card in cardLayout using JTree listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "I can Watch "I can New topic
Author

I can't change card in cardLayout using JTree listener

Marek Krokosinski
Ranch Hand

Joined: Jun 10, 2011
Posts: 64
Hello

I have problem with changing card. I have a JPanel with CardLayout as layout, and other JPanel which contains JPanel with JTree. I want to add TreeSelectionListener. If I click on the node, card should change to the node title.

Here is some code:

The listener from which I want to change cards is in the second code snippet under line 159.


JPanel with cardlayout:


Here are two classes which builds JTree:


and the second class, which add JTree to the gui:


Any ideas how could I change cards in ThumbPanel from the listener in JTreeHelper ?

I have also asked that question on stackoverflow
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
had to strip most of the unrelated stuff in the code.

this part now works OK

Marek Krokosinski
Ranch Hand

Joined: Jun 10, 2011
Posts: 64
Oh, why I didn't saw your post 20 minutes ago, now I have resolved my problem by putting everything in one class...

It's working as I wanted, but it looks terrible. I don't know if I want to change it now.

Anyway thank you for solution, and sorry for messy code in the first post, I will try to clean it up before posting it on the forum.
 
wood burning stoves
 
subject: I can't change card in cardLayout using JTree listener