This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing Panels after clicking JButton  RSS feed

 
mel li
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 JPanels in my code. The first one is Furutsu7 which is the main JPanel which includes my game. The second JPanel is the start Jbutton. What I'm trying to accomplish is after the user clicks the Jbutton, the Furutsu7 JPanel will appear.

This is my setup class where I created the buttons.





What I need help on is what should I put in my action performed in order to switch to the Furutsu JPanel.

 
Fred Kleinschmidt
Bartender
Posts: 560
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could just do this:

It would be a better idea to use variables to hold the card names so you don't ever misspell things when you later reference them:


But you may need to rethink the design of your program.
Once the Fujutsu panel is displayed, how will the user exit the program?
The "Exit" button is on the hidden panel. How wil you get back to it?
You might want to use a JMenu instead of another card to hold the buttons.
 
Rob Camick
Ranch Hand
Posts: 2801
15
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!