Hi everyone,

I'm trying to build a GUI for a project I'm working on, and I'm having trouble working out how to move between different displays within the same GUI.

I have a simple GUI with a menu bar and two buttons in the content pane. If the user clicks button A, I'd like for the user to move to a different content pane or GUI (not sure which is better) with the same menu bar, much like how a user moves between webpages in a browser.

So far I've managed to have it so that when the user clicks button A, a whole new GUI is displayed, but this isn't exactly what I want.

Any ideas on how to go about this? I'm sure it's pretty basic but I haven't managed to find anything on this so far. Thanks in advance!

Take a look the CardLayout layout manager.
It displays one component at a time.
You can set this as the layout manager of the main panel of the JFrame.
You can then create a separate JPanel for each "page" of your GUI and show the appropriate "page" when user clicks a button.
I think that the documentation can explain it better then I can.

Thanks sergb!

Using the CardLayout class sorted it out quite nicely.

This question has already been answered. Start a new discussion instead.