Hi, I am programming a naval battle game using Swing and I have run into some problems:
When I tell the user to place his ship, I need a program to wait, like a modal dialog - so thet game won't start until the ship is placed, but the gui is not frozen.
Kind of this code:
public void newGame(){
askUserAboutName(); //uses JOptionPane.showInputDialog - program freezes until user fills in the name
askUserToPlaceShips(); //cannot use JOptionPane - placing is a mouse event (click) on existing component, but need to freeze until placed
startGame();
}
So - I need to freeze the code on the second command - wait for user to place ships. Basically, it's the same like asking him about name, but placing ships dont use modal dialogs - it uses mouse listener on existing frame (the board), so when the users clicks, the ship is placed.
Hope I made myself clear.
TY for response.