943,831 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 556
  • Java RSS
Apr 29th, 2009
0

CardLayout Question

Expand Post »
Hi,

I am trying to make a gui in which I import and combine 4 seperate classes JPanel classes that I made into one interface. But I am running into an obstacle that I am uncertain about.

Here is the situation:
1. I have container using a BoxLayout that has 2 panels one stacked on the other.
2. In the top panel I put the imported panel class that is needed for every transaction. This imported panel has a combobox
3. the bottom panel uses CardLayout and I want its contents (one of 3 other imported panel classes) to be governed by the status of the combobox in the top panel.

Is this possible? if so could someone explain how I would go about it?

Thanks!
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
klactose is offline Offline
43 posts
since Feb 2008
Apr 29th, 2009
0

Re: CardLayout Question

Yes, it is possible. It is actually pretty easy. Before you get into it though, I'd recommend that if you have different sized panels, you do not use cardlayout, as I tried this, and it is very difficult to resize them.

http://java.sun.com/docs/books/tutor...yout/card.html

Use this link to learn how to do it. You'll need to use the show() method that you see there to switch panels based on what is in the combobox. The code to do that will be in the combobox's actionPerformed method. Ask me if you have any other questions after you read the tutorial. It is a fairly simple tutorial.
Reputation Points: 874
Solved Threads: 352
Posting Maven
BestJewSinceJC is offline Offline
2,758 posts
since Sep 2008
Apr 29th, 2009
0

Re: CardLayout Question

Hello and thanks for the response. Yes I have seen that tutorial but my problem is slightly different as the panels are not defined in the same class. All of the children panels of the main container are imported classes that I created separately.

What I don't understand is how to make the combobox from one imported child panel propagate its changed state up to the main container so that the main container's itemStateChanged method can be used to change which card is displayed.

Thanks!
Reputation Points: 10
Solved Threads: 1
Light Poster
klactose is offline Offline
43 posts
since Feb 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: an easy error message
Next Thread in Java Forum Timeline: reading Input from File





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC