E
electric sheep
o.k.
on the sun website they have these cryptic words:
To avoid the possibility of deadlock, you must take extreme care that
Swing components and models are created, modified, and queried only from
the event-dispatching thread.
and they give this sample code:
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
my question is this.
"create and modify" means just that ... even creating.
i had thought of making a class, having it extend JFrame and implement
Runnable, like so:
class MyGUI extends JFrame implements Runnable {
MyGUI()
...
public void run()
...
}
then do:
javax.swing.SwingUtilities.invokeLater(new MyGUI());
but in fact, that wouldn't be following Sun's advice to the letter i
guess, would it ?
Because the JFrame object (MyGUI) would be created, and then the handle
to this object would be passed to invokeLater().
So in fact, part of the GUI would have already been created in the
"main" thread.
So I guess I need to create my MyGUI object from within a method, say
createGUI(), as opposed to "on-the-fly" like this ?
on the sun website they have these cryptic words:
To avoid the possibility of deadlock, you must take extreme care that
Swing components and models are created, modified, and queried only from
the event-dispatching thread.
and they give this sample code:
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
my question is this.
"create and modify" means just that ... even creating.
i had thought of making a class, having it extend JFrame and implement
Runnable, like so:
class MyGUI extends JFrame implements Runnable {
MyGUI()
...
public void run()
...
}
then do:
javax.swing.SwingUtilities.invokeLater(new MyGUI());
but in fact, that wouldn't be following Sun's advice to the letter i
guess, would it ?
Because the JFrame object (MyGUI) would be created, and then the handle
to this object would be passed to invokeLater().
So in fact, part of the GUI would have already been created in the
"main" thread.
So I guess I need to create my MyGUI object from within a method, say
createGUI(), as opposed to "on-the-fly" like this ?