• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing Panels after clicking JButton

 
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: 454
3
  • 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: 2699
10
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!