Archived

This topic is now archived and is closed to further replies.

[java] Switching Screens

This topic is 5116 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone, I''ve been working on a space strategy game and have finally decided to make it a full-screen application. A question I have is, what is the best way to switch "screens"? For example, I want to have an introductory screen appear first, which then brings up another screen depending on which option the user selects ("New Game," "Load Game," etc.). Right now, I have these different screens as individual classes extending the JFrame class. Is this a good design, or should I do something else? - Rob

Share this post


Link to post
Share on other sites
What I do for something like this is, I have one main JFrame class, that doesnt do anything but hold extended JPanel classes. Then I just have the JFrame switch about the JPanels when needed. It can get a bit messy, but it works pretty good whenever I use it.

Share this post


Link to post
Share on other sites
For switching between menus, I decided I would write a menu manager, which would load up an XML file that described how the menus should switch between each other.

The main app only had to call the loadfile function, and Show Menu function... the switching and logic was handled by the manager. To recieve inputs from various buttons I implemented that through a base action class, that any class wishing to get messages must derive from, and then register the component with the menu manager.

For a look at my source, feel free to take a look at some doxygenerated html files here

Now I am using some various third party libs (Ogre, Fmod, Raknet) but the general functionality should be fairly obvious.

Check here for a small sample (Not all button components are hooked up... And remember, I'm a coder, not an artist) WindowsXP/2000 Binaries

[edited by - pjcast on December 15, 2003 3:37:23 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Ditto Brother Rat
You might want to look into CardLayout if you haven''t already...


That sounds exactly like what I''m looking for! Thanks!

- Rob

Share this post


Link to post
Share on other sites