int x = Integer.parseInt(JOptionPane.showInputDialog("INPUT 1 FOR GAME, ANY FOR EXIT"));
while(x == 1){
new PokelanzBattle();
x = Integer.parseInt(JOptionPane.showInputDialog("INPUT 1 FOR GAME, ANY FOR EXIT"));
}
In this code, assuming that you entered 1, the while will run. In the while loop, I want to run PokelanzBattle() method ONLY, but after running it the next line will also be read and run.
How can I run only the method and after I dispose the gui(the gui/method will dispose automatically, with some method inside), the next line will run which is the input dialog box.
A better way would be ask for a re-game when your game actually ends.Something like :
int x = Integer.parseInt(JOptionPane.showInputDialog("INPUT 1 FOR GAME, ANY FOR EXIT"));
if(x == 1)
{
new PokelanzBattle();
}
And when game is over:
int x = Integer.parseInt(JOptionPane.showInputDialog("GAME OVER!!! INPUT 1 FOR GAME, ANY FOR EXIT"));
if(x == 1){//....