How does JOptionPane works?
hello
I'm trying to make a frame that each time that you open it, it returns a value (like the dialogs in JOptionPane). the problem is that when I do so, using a boolean loop, that exits when the ok button is pressed, then it shows only a blank frame without all its components and so on.
I guess this happen because I call the loop inside the main event thread. I tried look in the JOptionPane code but didn't understand it
[445 byte] By [
TheHattera] at [2007-10-2 18:50:44]

In your modal dialog do something like this:
class myDialog extends JDialog{
int result = JOptionPane.CANCEL_OPTION;
public MyDialog(){
setModal (true);
}
private int showDialog(){
setVisible (true);
return result;
}
private void okButtonSelected(){
result = JOptionPane.OK_OPTION;
setVisible(false);
}
private void cancelButtonselected(){
result = JOptionPane.CANCEL_OPTION;
setVisible(false);
}
}
From your frame call showDialog. Your main frame will be blocked at the call to setVisible until something else calls setVisible(false). Then showDialog will return the result.