I think JOptionPane works a little like the Windows Form (in Java/C#) 'MessageBox'. The function halts until, for example, input is recieved. i.e
PHP Code:
if (MessageBox.Show("Bla Bla Bla") == [some button stuff])
Excuse the broken code (rusty), but (if completed) that shows a message box, and halted the function until the user acted on the MessageBox.