I'm developing a game and i want the application to ask the user to input a name at the begining
publicclass GameWindow {
static String nameStr; }
public GameWindow{
nameStr = JOptionPane.showInputDialog(null, "Enter Name", "Please enter a name:");
playerArray[0] = new Player(nameStr);
}
As you can see, if name is entered and ok is pressed then it saves to the player array. I also want the application to exit if cancel is pressed, but i don't know how to do that.
Q2:
In the same application I have a menu bar and I want it to appear before the user is asked to enter a name. Unofrtunately java is not as sequential as pascal. It doesn't allow me to display the menubar before the input dialog even if i put the menubar code before the showInputDialog. So how can I solve this problem?