wait for dialogue box

is ti possible to have to program have a dialogue box pop up and then wait until the user presses ok. if so, how?

thanks in advance.


      int i = JOptionPane.showConfirmDialog(null,"Text","Title",JOptionPane.DEFAULT_OPTION);
      System.out.println("Dialog closed ");

There’s a bunch of different methods like this in JOptionPane so you should look at the documentation to find which kind you want, but they all look basically like this.

Also have a look at Frames and Dialogs in the Java tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/frame.html
http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html