Re: Canvas Wanted (simple question)
On 12/23/2011 4:49 PM, Joerg Meier wrote:
On Sun, 11 Dec 2011 15:55:53 -0800, Knute Johnson wrote:
public static void main(String[] args) {
// create GUI on EDT (event dispatch thread)
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.add(new test(),BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
});
}
Just a small nitpicking note, this code block doesn't need to be wrapped in
invokeLater (because there is no EDT before the setVisible, so there are no
threading concerns).
Liebe Gruesse,
Joerg
I don't think you will find that position anywhere in Sun's
documentation. In fact they specify that you must create the Swing
components on the EDT. In the code above, how could it possibly run if
there was no EDT until the setVisible() method was called?
--
Knute Johnson