So im trying to creat a Jpanel with a comboBox at the top, with 2 options, when choose options you get different "screens" in the jpanel but the comboBox stays, i know how to create comboBox and ActionLister but my question is how do i change the screens? do put different panels in the jframe? any ideas?
Asked
Active
Viewed 188 times
0
-
what does you mean by screen ? – Sage Oct 06 '13 at 17:30
-
like a set of different options in the frame, screen is a pretty bad word to describe it :-) – Gigalala Oct 06 '13 at 17:45
-
2You would use a CardLayout to swap JPanel "views" held in another JPanel. – Hovercraft Full Of Eels Oct 06 '13 at 17:48
-
JSE doesn't have such component other than JTabbedPan which allow you to put different panel with tabs to browse amon them. you can add your combobox action to select a tab with corresponding screen. Otherwise you need to write your own custom component with layout. Let us know a little more detail – Sage Oct 06 '13 at 17:51
-
@Sage: what are you talking about? Your comment above does not make sense. To the original poster, you might want to be careful with sage's advice. Again, a CardLayout would likely work just fine. – Hovercraft Full Of Eels Oct 06 '13 at 17:53
-
I just answered as much as i understood Gigala's question and i am pretty confused about the screen he mentioned. If he wants an option like navigation of different set of options like we do in a TextEditor JTabbedPan is a good choice. **I did mention about layout too. And i did ask him about more details!**, so beat some more sense in me. – Sage Oct 06 '13 at 18:13
1 Answers
1
im trying to create JPanel with a comboBox at the top, with 2 options, when choose options you get different "screens" in the jpanel but the comboBox stays
Read the section from the Swing tutorial on How to Use Card Layout for a working example that does exactly what you want.

camickr
- 321,443
- 19
- 166
- 288
-
See also the examples [here](http://stackoverflow.com/a/6047101/230513) and [here](http://stackoverflow.com/a/6432291/230513). – trashgod Oct 06 '13 at 23:43