I’m trying to understand which events will be managed from an event disptach thread (EDT).
Let’s assume something simple, a simple piece of code that simple opens a JOptionPane, waits for the user’s response, then closes it. What events related to this object are now put on the EDT? Is it:
a) Just the creation of the object (the JOptionPane).
b) All object related events for the lifetime of the object.
C) Something else (please specify).
Thank you,
Elliott
See below:
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run(){
JOptionPane.showMessageDialog(myComponent, msg);
}
});
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
As far as I can remember, all the following “events” will be executed in the EDT:
SwingUtilities.invokeAndWait()orSwingUtilities.invokeLater().