• Post Reply Bookmark Topic Watch Topic
  • New Topic

displaying alternate jpanels in a jframe

 
samual smith
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i want to display the attack jpanel in the same frame when the button is clicked but instead it opens in a new frame

 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Please UseCodeTags next time, but don't forget to maintain the indentation. I've added both this time.

You are creating a new JFrame which you are then showing. You should instead change the current frame. The usual way is to use a CardLayout.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!