I would suggest checking out the documentation for JOptionPane. If you'll look, you'll see that JOptionPane has a required first argument which specifies a parent frame - if you pass it a null, I think this should work. It's been roughly FOREVER since I did any Java, so check it for yourself.
Docs appear to be here, based on lazy googling. http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JOptionPane.html