Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #4856

Re: Canvas Wanted (simple question)

From markspace <-@.>
Newsgroups comp.lang.java.gui
Subject Re: Canvas Wanted (simple question)
Date 2011-12-23 17:26 -0800
Organization A noiseless patient Spider
Message-ID <jd39ov$s2l$1@dont-email.me> (permalink)
References <4ee52877$0$5797$65785112@news.neostrada.pl> <jc3fu9$31u$1@dont-email.me> <8lxthes2ckbz.x1cfm0fm94x5$.dlg@40tude.net>

Show all headers | View raw


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).


Wrong.  There's no defined mechanism for passing objects created on one 
thread to the EDT otherwise.  You still have to worry about safe 
publication or now.

Also, any listeners created by Swing objects may fire, and those fire 
*on the EDT*.  So you may indeed get an EDT before the call to 
setVisible().  Only creating these objects on the EDT is 100% safe.

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Canvas Wanted (simple question) Paweł Lampe <scony@sconysoft.com> - 2011-12-11 22:02 +0000
  Re: Canvas Wanted (simple question) Knute Johnson <nospam@knutejohnson.com> - 2011-12-11 15:55 -0800
    Re: Canvas Wanted (simple question) Joerg Meier <joergmmeier@arcor.de> - 2011-12-24 01:49 +0100
      Re: Canvas Wanted (simple question) markspace <-@.> - 2011-12-23 17:26 -0800
        Re: Canvas Wanted (simple question) Joerg Meier <joergmmeier@arcor.de> - 2011-12-24 03:41 +0100
          Re: Canvas Wanted (simple question) markspace <-@.> - 2011-12-23 21:42 -0800
            Re: Canvas Wanted (simple question) Joerg Meier <joergmmeier@arcor.de> - 2011-12-24 14:16 +0100
              Re: Canvas Wanted (simple question) markspace <-@.> - 2011-12-24 06:47 -0800
      Re: Canvas Wanted (simple question) Knute Johnson <nospam@knutejohnson.com> - 2011-12-23 21:21 -0800
        Re: Canvas Wanted (simple question) markspace <-@.> - 2011-12-23 21:48 -0800
      Re: Canvas Wanted (simple question) Joerg Meier <joergmmeier@arcor.de> - 2011-12-24 14:20 +0100
        Re: Canvas Wanted (simple question) "John B. Matthews" <nospam@nospam.invalid> - 2011-12-24 11:22 -0500
  Re: Canvas Wanted (simple question) Roedy Green <see_website@mindprod.com.invalid> - 2011-12-12 09:58 -0800
  Re: Canvas Wanted (simple question) Paweł Lampe <scony@sconysoft.com> - 2011-12-14 15:57 +0000
    Re: Canvas Wanted (simple question) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-12-14 10:21 -0800

csiph-web