I'm making a game in Java with Swing. I created a start menu. I want the game to start when I press the start button.
I have a start button in my startScreen object. I want to add game object to my frame when I press.
I try very bad way:
while(startScreen.isVisible()){
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
Logger.getLogger(Core.class.getName()).log(Level.SEVERE, null, ex);
}
}window.add(gameScreen);
What is the true way?