Minecraft PC IP: play.cubecraft.net

NanoNet

Dedicated Member
May 23, 2014
1,044
357
158
IKEA
As I was creating a very simple GUI, I wanted to create a JButton that when clicked(A "next" button), moves to a new "Page" or frame? So how would I go about doing this? Should I make it so when the button is clicked, the Current JFrame's visibility is false, and then set the new Frame to true? OR is there a better way to go about doing this?

Thanks for taking your time to read this :)
 

NanoNet

Dedicated Member
May 23, 2014
1,044
357
158
IKEA

alyphen

Well-Known Member
Jan 4, 2014
101
109
118
27
127.0.0.1
seventh-root.com
As you're using JButton, I'm going to assume you're using Swing.
Set the panel's layout to CardLayout. When you add each panel you want to switch between, you do so with add(myPanel, "stringIdentifierForPanel");
Then, when the button is clicked, call layout.show(parentPanel, "stringIdentifierForPanel");
That would achieve what you're looking for, I believe.
 
  • Like
Reactions: NanoNet

NanoNet

Dedicated Member
May 23, 2014
1,044
357
158
IKEA
As you're using JButton, I'm going to assume you're using Swing.
Set the panel's layout to CardLayout. When you add each panel you want to switch between, you do so with add(myPanel, "stringIdentifierForPanel");
Then, when the button is clicked, call layout.show(parentPanel, "stringIdentifierForPanel");
That would achieve what you're looking for, I believe.
I learn something new from you every time, thanks!
 
Members Online

Team online

Latest posts

Latest profile posts

TheOrderOfSapphire wrote on Abodz's profile.
Happy Birthday! I hope you have/had a good day today!:D
Reesle wrote on Abodz's profile.
Happy Birthday! 🎈
Reesle wrote on Ferrcho's profile.
Happy Birthday! 🥳
TheOrderOfSapphire wrote on Roxlad's profile.
Happy Birthday ^-^
TheOrderOfSapphire wrote on Ferrcho's profile.
Happy Birthday!:D
Top Bottom