-1

Building a GUI with one JFrame holding two JPanels.

1) Panel 1 is Start screen and will stay visible until close.
3 Buttons - Start, Settings, Exit
Start: Exits GUI Interface & Opens "Live" Ticker style text display to multiple TV's.
Settings: Need to open 2nd JPanel which will be the Settings Panel with JTabbedPane included.
Exit: Exits Program.

2) Panel 2 Needs to be invisible until Settings JButton selected in Panel 1.
Panel 2 will sit on top of Panel 1 (like a color chooser box) within either the JFrame's surface area or Panel 1's surface area (Whichever is recommended or will work).
Panel 2 will be set to invisible again when the Exit JButton is selected in Panel 2.

I have been looking for past 2 days for answers, CardLayout doesn't seem to fit since I am not replacing the 1st Panel. I have been unable to get the JTabbedPane to work within a JOptionPane or Dialog Box.

Need some help here if you can....

2 Answers2

2

2) Panel 2 Needs to be invisible until Settings JButton selected in Panel 1. Panel 2 will sit on top of Panel 1 (like a color chooser box) within either the JFrame's surface area or Panel 1's surface area (Whichever is recommended or will work). Panel 2 will be set to invisible again when the Exit JButton is selected in Panel 2.

I have been looking for past 2 days for answers, CardLayout doesn't seem to fit since I am not replacing the 1st Panel. I have been unable to get the JTabbedPane to work within a JOptionPane or Dialog Box.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • he doesnt want a Cardlayout. – Oliver Watkins Jun 25 '13 at 14:15
  • 1
    +1 mKorbel... OliverWatkins IMO maybe the OP doesnt even know what he/she wants or is misguided on the use of CardLayout. The problem specified is easily solvable with CardLayout. @KrisLambert check [this](http://stackoverflow.com/questions/14011397/how-to-add-jpanel-by-clicking-jbutton/14012757#14012757) example of CardLayout. as for *CardLayout doesn't seem to fit since I am not replacing the 1st Panel* CardLayout is not about replacing a component simply about showing components dynamically (i.e on click of a button) – David Kroukamp Jun 25 '13 at 14:18
  • "Panel 2 will sit on top of Panel 1 (like a color chooser box) within either the JFrame's surface area or Panel 1's surface area".. sitting on top, sounds more like a dialog to me. – Oliver Watkins Jun 25 '13 at 14:30
  • @mKorbel It is currently in GroupLayout and was hoping to not have to switch layouts as it is nearly completed. –  Jun 25 '13 at 14:36
  • @OliverWatkins For some reason it didn't work earlier but I did finally get the panel into a dialog box. Thanks for the recommendation to make me consider it again! –  Jun 25 '13 at 14:42
  • @OliverWatkins change your comment to an answer so that I can mark it when you can please. Thank you everyone for the quick replies. –  Jun 25 '13 at 15:02
  • @Kris Lambert please really whats goal, – mKorbel Jun 25 '13 at 15:37
  • ![sample](https://www.dropbox.com/s/s3r6y5pfzk5p4nl/sample.PNG) @mKorbel This is the image of what I was trying to fix. I knew it wasn't a good idea to use multiple frames in the GUI. So I was trying to use two Panels and hide one until button pressed. When I tried using a dialog box before I could not get it to accept the TabbedPane, but after Oliver suggested it again I tried one last time and it worked. So I was able to put the tabbedPane into a dialog box which hides itself until the settings button is pressed, and do away with the extra panel I had the tabbedPane in as well. –  Jun 25 '13 at 15:50
  • I'd be use JList & CardLayout (renderer, coloring, highlighting, listselectionlistener) on left side instead of JTabbedPane, all JButton (in JPanel) should be placed on south, rest of global commands (if will be there) to put to JMenu(Items), otherwise you'll ended that some of required Actions are dirty hacks by using JTabbedPane – mKorbel Jun 25 '13 at 15:55
  • I will look into that. I am porting an old program to Java and trying to keep visually and functionally the same so there is no user interface issues. After editing, it just brings up the blue screen with the buttons, and then the settings tabs in the dialog box. –  Jun 25 '13 at 16:02
  • @mKorbel I did finally get a better understanding of card layout. I ended up using the JDialog approach instead of the two panels but I do see how CardLayout would have solved the approach I was taking. –  Jul 25 '13 at 04:31
0

@OliverWatkins Solution of using a jDialogBox solved this situation best. The jTabbedPane that was being held in the second jPanel was instead placed into a jDialogBox that is able to be opened by ActionEvent from my jButton and delivered the desired result.