0

Hello lovely community,

I'm Leon and at developing a little jump n run.I'm sitting since rough 24 hours on the laptop to find a solution for my problem. So my GUI starts up with a little menu, in it buttons titled for example with "start game". By clicking this button the game starts. BUT it starts in a new JFrame respectively it starts in a new window.. by playing the puzzle you can press escape for launching the pause menu. BUT again, it opens up in a new window. I need desperately a solution because I cant go on with coding.. Hope anyone can help me. THX Sorry for my English. Leon ;)

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • 1
    Hard to answer without code. I suspect you create a total of 3 JFrames. You should have one main JFrame and swap out JPanels in that JFrame. – stealthjong Aug 15 '14 at 13:13
  • 1
    1) For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal, Complete, Verifiable Example). 2) Use a [`CardLayout`](http://download.oracle.com/javase/8/docs/api/java/awt/CardLayout.html), as shown [here](http://stackoverflow.com/questions/5665156/calling-awt-frame-methods-from-subclass/5786005#5786005). – Andrew Thompson Aug 15 '14 at 14:58

1 Answers1

0

Don't use jbuttons. Whenever I make swing based game I use 1 jpanel in which I override paint method and create my own buttons (you'll need to give them functionallity with mouse/key listener, but that is not hard to figure out. If you want to see example code, look up the way minecraft creator does it (google "notch ludum dare" - all games have source code attached)

Arvy
  • 95
  • 12