> > I have one GUI that opens up a second GUI in a different class. How can I
> > get the first GUI to pause until the OK (or cancel) button is pressed on the
> > second GUI? I'm using Swing, JDK1.3.
>
> Check out the JOptionPane class.
> 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
PM - 31 May 2005 14:13 GMT
> > 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
[quoted text clipped - 5 lines]
> your case, I would translate your JFrame into a JPanel, and then you
> call the following (for example):
<code snipped>
Many thanks for your detailed reply.
Pete