| | |
CardLayout Question
![]() |
•
•
Join Date: Feb 2008
Posts: 42
Reputation:
Solved Threads: 1
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!
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!
•
•
Join Date: Sep 2008
Posts: 2,228
Reputation:
Solved Threads: 274
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.
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.
•
•
Join Date: Feb 2008
Posts: 42
Reputation:
Solved Threads: 1
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!
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!
![]() |
Similar Threads
- drop down menu question (Java)
Other Threads in the Java Forum
- Previous Thread: an easy error message
- Next Thread: reading Input from File
Views: 367 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Java
access add android applet arguments array arrays binary bluetooth build c++ chat class classes client code combobox component constructor convert converter data database db design detection eclipse error event exception file forloop game givemetehcodez graphics gui helpwithhomework homeworkassignment html ide image inheritance input integer interface j2me java javafx jframe jpanel jtable julia lazy linked linked-list list loop looping method methods mobile netbeans newbie number object objects os output parameter pattern pixel printing problem programming project read recursion remote remove return robot scanner search server service set size sms sql string swing system test text text-file timer transfer translate tree web






