简体   繁体   中英

Java Swing - What's the proper way of doing a stage based GUI?

I'm currently developing the menu of my application and I would like to know what's the proper way of coding a "stage based menu". What I mean by stage based menu is that, user clicks a button, the entire interface changes to the next "stage". Here are the pictures I designed in Photoshop in order to explain my idea: 主菜单

管理菜单

First picture would be the first stage and the second picture the second. Each round looking thing is a JButton

So far I got the main menu (fist picture) made on eclipse using WindowBuilder, made it as a JPanel and then I instantiate it on the window class.

My idea was to have an event listener listen for clicks on each button and then once the even is triggered, have the JPanel variable on the frame change to the next "stage". So I was wondering if this is actually the proper way of doing this or are there any better ways?

You could use a Card Layout to make it easy to swap panels.

Check out the section from the Swing tutorial on How to Use Card Layout for more information and examples.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM