• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

I can't change card in cardLayout using JTree listener

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
had to strip most of the unrelated stuff in the code.

this part now works OK

 
Marek Krokosinski
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!