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


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

Re: Sharing ListSelection

From "Lew" <lew@THRWHITE.remove-dii-this>
Subject Re: Sharing ListSelection
Message-ID <dNadnR53z6_X_2fVnZ2dnUVZ_judnZ2d@comcast.com> (permalink)
Newsgroups comp.lang.java.gui
References <48fa372e$1@news.uni-rostock.de>
Date 2011-04-27 15:50 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Lew schrieb:
>> And here you finally push code onto the EDT, but the construction was not.

Stefan Rybacki wrote:
> I'm not aware that the construction actually needs to be pushed to the
> EDT. Why should I? I mean what if the construction takes a while for
> whatever reasons the EDT is blocked? Do you have any resource stating
> that also the construction should be pushed to the EDT?

 From the Swing tutorial,
<http://java.sun.com/docs/books/tutorial/uiswing/concurrency/initial.html>
> An initial thread schedules the GUI creation task by invoking 
> javax.swing.SwingUtilities.invokeLater or 
> javax.swing.SwingUtilities.invokeAndWait.
...
> Why does not the initial thread simply create the GUI itself? 
> Because almost all code that creates or interacts with Swing components 
> must run on the event dispatch thread. 

Also, see the paragraph on "Main Method" and associated example from:
<http://en.wikibooks.org/wiki/Java_Programming/SwingLargeExamples>

Understand that the documentation for Swing says that ALL methods and 
components must be accessed only from the EDT unless explicitly marked 
thread-safe.  They make no exception for constructors.
<http://java.sun.com/docs/books/tutorial/uiswing/concurrency/dispatch.html>

The reason is that the threading model could allow EDT events to begin before 
the constructor completes unless you adhere to the dictum.  State might not 
transfer correctly between threads, given the memory model.

Such anomalies were observed in the field, which is why Sun updated its 
documentation.  They used to go ahead and tell people to construct GUIs on the 
initial thread, but now no longer.

-- 
Lew

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

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


Thread

Sharing ListSelectionMode "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
  Re: Sharing ListSelection "Sabine Dinis Blochberger" <sabine.dinis.blochberger@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
    Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
      Re: Sharing ListSelection "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
        Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
          Re: Sharing ListSelection "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
            Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
              Re: Sharing ListSelection "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
                Re: Sharing ListSelection "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000
            Re: Sharing ListSelection "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:50 +0000

csiph-web