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 posts

Latest profile posts

This is YOUR daily dose of facts #52-
The minecraft music disc 11 lasts for 1 minute, 11 seconds and 111 milliseconds!
It was hard writing this on a tv (yes, I sometimes write facts on a tv lol).
Basketman wrote on Roxlad's profile.
Happy Birthday!
me after realizing my uncle started watching jjk: 😨💀
UncleSpect wrote on xSchulzis's profile.
Hiiii xSchulzis! :D
UncleSpect wrote on Roxlad's profile.
Happy birthday! 🎈
Top Bottom