# JFrame launcher stays open when I'm finished with it

I have written a launcher that prompts the user for their name then starts the game when they hit enter. The launcher looks like this:

But when the user hits enter, this happens:

The launcher stays open.

This is the relevant code in the launcher class:

    public void actionPerformed(ActionEvent evt) {
String text = textField.getText();
System.out.println(text);
entered=true;
Game game = new Game();
game.start(text);
}

public void Launch() {
//Create and set up the window.

// maximize the jframe here
frame.setSize(800,600);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Display the window.
frame.pack();
frame.setVisible(true);
while(entered==true){}
}


And this is for the main method in the game:

    public static void main(String[] argv) {
Launcher launcher = new Launcher();
launcher.Launch();
}


So how would I go about closing the launcher when the user has no use for it?

I am using a JFrame for the launcher and Lwjgl for the actual game window.

• I've edited your question to remove the irrelevant code. When you include all your code, it looks like you don't have any idea what you're doing and clutters the question. For example, in a problem like this, we can assume that you have all the required include statements, there's no need to include them, same goes for your rendering code. – MichaelHouse Mar 8 '13 at 15:28