Re: How to get one GUI to wait for input on second GUI



> JOptionPane looks good, does the showInternal frame allow me to put, say, OK
> and Cancel buttons on an internal frame on my GUI, and still have the rest
> of the GUI (mainly a JTable) as normal? How does this work if I need to
> extend JOptionPane for my GUI class which previously extended JFrame?

The JOptionPane class will allow you to give any JComponent as argument
as well as which buttons and which Icon you want as argument. So in
your case, I would translate your JFrame into a JPanel, and then you
call the following (for example):

JOptionPane jOpt = new JOptionPane(yourPanel,
JOptionPane.QUESTION_MESSAGE,
JOptionPane.OK_CANCEL_OPTION);
JDialog dialog = jOpt.createDialog(parentPanel, "");

dialog.setVisible(true);
Object val = jOpt.getValue();
// Check for yes or no button pressed
if(val != null) {
if(val instanceof Integer) {
int intVal = ((Integer)val).intValue();
if(intVal == JOptionPane.OK_OPTION) {
// do the stuff you want to do if the user presses ok
} else {
// do the stuff you want to do if the user presses cancel
}
}
}

Kind regards, Jonck

.