I’m developing a sim game based on Theme Hospital, which is quite an old game.
I’ve made lots of progress on the underlying workings, however now I am coming to the GUI elements, which I haven’t done alot of before. I am still rather new to java.
The effect I am trying to create is like shown here…
http://www.tubechop.com/watch/18438
Click on a button, opens up a panel with tabs to select from different selections, and then click a button to build a room. I believe for the “tabs” I can use a card layout? For the actual building of rooms, I am pretty much sorted. The main problem I have right now, is getting the panel to open up on the click of a button.
At current, I have 1 JFrame and 2 JPanels ontop, the main game panel and the control panel with a few buttons.
Can anyone show me some simple example of how I would do such a thing? I know its probably really simple, and I bet some of you could even write the code off the top of your head, but I am new to java, and have been taught more about the logical elements of programming so far rather than how to build a more complex multi layered GUI like required in a game.
I know it’s an ambitious project, but I have come a long way, and have even implemented custom path finding using A*, which I’m happy about (All thanks to you people here at StackOverflow!)
Thank you in advance for your help.
JDialogs would work, but they’re going to pop up new top level windows over your game window. You could implement your main game display and control panel as the background of a JDesktopPane(which extends JLayeredPane), and could make the pop ups JInternalFrames.
Contrived (but working) example: