The program stops for some wierd reason

I have a game which has the

  1. Main-class which extends Frame and listens to the keys.
  2. StartScreen-class which extends JPanel and it should be shown at the beginning of the game until user presses any key.
  3. Game-class which extends JPanel and it is pretty much the game part of this application.

The program works perfectly fine if I call the Game class directly from the Main-class’s constructor. I can even add the StartScreen to the Main and after that remove it and add Game to the Main class, but only if I do that in the Main’s constructor.

But. I’d like to keep that StartScreen on top until user presses any key. But it seems like the whole application just stops working after the Main’s constructor ends. It won’t even repaint the application anymore even if pressing any key should trigger the repaint()-method.

So, is there something I maybe don’t know about applications’ life? Because I really wouldn’t like to go straight into the game when the application starts.

edit: I was just thinking that should I maybe make the Main class to implement Runnable?

Aah, problem solved.

I created a loop in Main. Pretty obvious I guess, but took me a while to figure that out :slight_smile:

Well, now I have other problems (again) but maybe ill post here if I cant solve those.