Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing a JPanel  RSS feed

 
Ben Jones
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, well, hello. I'd generally class myself as a C++ coder, but, at uni' I'm required to do Java so I'm having to learn.

Well, I'm having to make a project and I've chose to do a really simple game. So far, I've got the start menu set up and the event listeners working to detect when I've pressed a button.

However, I'm using a JFrame, and inside that a JPanel with the various buttons and JPEG's inside. Obviously, when I click on the 'Start Game' button, I want to clear what's in the JFrame and open a new canvas to draw the the game on.

I was wondering, how do I do this? Hope I have enclosed enough information.

Dan.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a CardLayout.
 
Nacho Espinosa
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could remove the JPanel from the container of JFrame.

Or remove the content in the JPanel and insert the Canvas.

The JPanel has a removeAll method, if you use this then you must update the JPanel.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!