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

Latest profile posts

qKhalidd wrote on ignsinf's profile.
Hi
TheOrderOfSapphire wrote on ii6xxq's profile.
welcome to the forums! I hope you will have a nice stay here:D
This is YOUR daily dose of facts #41-
The moon has moonquakes, which are kind of like the earthquakes on the Earth, but weaker.
Basketman wrote on Eli's profile.
Favourite how to tame a dragon movie, shoot.
Reesle wrote on ii6xxq's profile.
Welcome to the Official Cubecraft Forums!! Hope you enjoy your stay :)
Top Bottom