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

Members online

Latest profile posts

Frontlane wrote on Egg🥚's profile.
Happy birthday 🥳
dvodany wrote on Egg🥚's profile.
Happy b-day! 🍰
WorriedSkate940 wrote on Egg🥚's profile.
Happy birthday!!!
denki_kiri wrote on savina875's profile.
Thanks for the follow :D
Desiderata wrote on Egg🥚's profile.
eggs age over time

how curious
Top Bottom