M
Marcin Rodzik
Being aware of what has been said http://ow.ly/1I50n http://ow.ly/1I50J
I'd like to ask explicitly: what should I do if I want to display some
information to the user in a Swing GUI app using a JDialog? I know
dialogs are event-driven so that execution of the thread which
requested displaying the dialog stops, but other currently fired
events are still handled.
The thing I don't know and I'd like to is: should I create a Runnable
object and schedule it for execution:
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
/* display the dialog here */
}
});
or:
I can simply write the code like this:
JOptionPane.showMessageDialog(parent, msg, title, messageType);
without the SwingUtilities stuff and Swing will handle the code
correctly anyway? I used to follow the first option but now I doubt if
it makes any sense.
regards,
Marcin
I'd like to ask explicitly: what should I do if I want to display some
information to the user in a Swing GUI app using a JDialog? I know
dialogs are event-driven so that execution of the thread which
requested displaying the dialog stops, but other currently fired
events are still handled.
The thing I don't know and I'd like to is: should I create a Runnable
object and schedule it for execution:
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
/* display the dialog here */
}
});
or:
I can simply write the code like this:
JOptionPane.showMessageDialog(parent, msg, title, messageType);
without the SwingUtilities stuff and Swing will handle the code
correctly anyway? I used to follow the first option but now I doubt if
it makes any sense.
regards,
Marcin