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

UncleSpect wrote on xSchulzis's profile.
Hiiii xSchulzis! :D
UncleSpect wrote on Roxlad's profile.
Happy birthday! 🎈
UncleSpect wrote on WolfX's profile.
Happy birthday! 🎈
UncleSpect wrote on Ferrcho's profile.
Happy birthday! 🎈
Heya, after a good while years having not appreciated sleep a lot, have I learned things. I have most of the times seen it as a hindrance to things such as relations and projects. But after years I realised that you need to sleep to be well. Both physically and mentally. When I also realized that I could work better and more efficiently, did I try to get more sleep. That reminds me, I need to sleep now hah XD
Top Bottom