File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: I can't change card in cardLayout using JTree listener
 
Similar Threads
Gett8ing focus when 2 JTrees in same panel.
JPopup and JTree Problem
I am lost , Help Me Please ...JTree
Jtree - message becomes blurry when scrolls
how to fill the jtree with the last modified value ?