< prev index next >

src/java.desktop/share/classes/javax/swing/package.html

Print this page




  21 You should have received a copy of the GNU General Public License version
  22 2 along with this work; if not, write to the Free Software Foundation,
  23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  24 
  25 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  26 or visit www.oracle.com if you need additional information or have any
  27 questions.
  28 -->
  29 
  30         <META NAME="Author" Content="Eric Armstrong">
  31         <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
  32         <TITLE>swing package</TITLE>
  33 </HEAD>
  34 
  35 <BODY bgcolor="white">
  36 
  37 <P>Provides a set of &quot;lightweight&quot;
  38 (all-Java language) components that,
  39 to the maximum degree possible, work the same on all platforms.
  40 For a programmer's guide to using these components, see
  41 <a href="http://java.sun.com/docs/books/tutorial/uiswing/index.html" 
  42 target="_top">Creating
  43 a GUI with JFC/Swing</a>, a trail in <em>The Java Tutorial</em>.
  44 For other resources, see 
  45 <a href="#related">Related Documentation</a>.
  46 
  47 <H2><a name="threading">Swing's Threading Policy</a></h2>
  48 
  49 In general Swing is not thread safe. All Swing components and related
  50 classes, unless otherwise documented, must be accessed on the event
  51 dispatching thread.
  52 <p>
  53 Typical Swing applications do processing in response to an event
  54 generated from a user gesture. For example, clicking on a {@code
  55 JButton} notifies all {@code ActionListeners} added to the {@code
  56 JButton}. As all events generated from a user gesture are
  57 dispatched on the event dispatching thread, most developers are not
  58 impacted by the restriction.
  59 <p>
  60 Where the impact lies, however, is in constructing and showing a
  61 Swing application. Calls to an application's {@code main} method,


 106     }
 107 }
 108 </pre>
 109 This restriction also applies to models attached to Swing components.
 110 For example, if a {@code TableModel} is attached to a {@code
 111 JTable}, the {@code TableModel} should only be modified on the
 112 event dispatching thread. If you modify the model on a separate
 113 thread you run the risk of exceptions and possible display
 114 corruption.
 115 <p>
 116 As all events are delivered on the event dispatching thread, care must
 117 be taken in event processing. In particular, a long running task, such
 118 as network io or computational intensive processing, executed on the
 119 event dispatching thread blocks the event dispatching thread from
 120 dispatching any other events. While the event dispatching thread is
 121 blocked the application is completely unresponsive to user
 122 input. Refer to {@link javax.swing.SwingWorker} for the preferred way to do such
 123 processing when working with Swing.
 124 <p>
 125 More information on this topic can be found in the
 126 <a href="http://download.oracle.com/javase/tutorial/uiswing/">Swing tutorial</a>,
 127 in particular the section on
 128 <a href="http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
 129 
 130 
 131 <H2>
 132 <a name="related">Related Documentation</a>
 133 </H2>
 134 <P>For overviews, tutorials, examples, guides, and other documentation, please see:
 135 
 136 <UL>
 137    <LI><A HREF="http://java.sun.com/products/jfc/tsc/" 
 138    target="_top">The Swing Connection</A>
 139    <LI><A HREF="http://java.sun.com/docs/books/tutorial/" 
 140    target="_top">The Java Tutorial</A>
 141    <LI><A HREF="http://java.sun.com/developer/onlineTraining/" 
 142    target="_top">Online Training</A> at the Java Developer Connection<font size=-2><sup>SM</sup></font>
 143    <LI><A HREF="http://java.sun.com/products/jfc/" 
 144    target="_top">Java Foundation Classes (JFC)</A> home page
 145 </UL>
 146 
 147 @serial exclude
 148 
 149 </BODY>
 150 </HTML>
 151 


  21 You should have received a copy of the GNU General Public License version
  22 2 along with this work; if not, write to the Free Software Foundation,
  23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  24 
  25 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  26 or visit www.oracle.com if you need additional information or have any
  27 questions.
  28 -->
  29 
  30         <META NAME="Author" Content="Eric Armstrong">
  31         <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
  32         <TITLE>swing package</TITLE>
  33 </HEAD>
  34 
  35 <BODY bgcolor="white">
  36 
  37 <P>Provides a set of &quot;lightweight&quot;
  38 (all-Java language) components that,
  39 to the maximum degree possible, work the same on all platforms.
  40 For a programmer's guide to using these components, see
  41 <a href="http://docs.oracle.com/javase/tutorial/uiswing/index.html"
  42 target="_top">Creating
  43 a GUI with JFC/Swing</a>, a trail in <em>The Java Tutorial</em>.
  44 For other resources, see 
  45 <a href="#related">Related Documentation</a>.
  46 
  47 <H2><a name="threading">Swing's Threading Policy</a></h2>
  48 
  49 In general Swing is not thread safe. All Swing components and related
  50 classes, unless otherwise documented, must be accessed on the event
  51 dispatching thread.
  52 <p>
  53 Typical Swing applications do processing in response to an event
  54 generated from a user gesture. For example, clicking on a {@code
  55 JButton} notifies all {@code ActionListeners} added to the {@code
  56 JButton}. As all events generated from a user gesture are
  57 dispatched on the event dispatching thread, most developers are not
  58 impacted by the restriction.
  59 <p>
  60 Where the impact lies, however, is in constructing and showing a
  61 Swing application. Calls to an application's {@code main} method,


 106     }
 107 }
 108 </pre>
 109 This restriction also applies to models attached to Swing components.
 110 For example, if a {@code TableModel} is attached to a {@code
 111 JTable}, the {@code TableModel} should only be modified on the
 112 event dispatching thread. If you modify the model on a separate
 113 thread you run the risk of exceptions and possible display
 114 corruption.
 115 <p>
 116 As all events are delivered on the event dispatching thread, care must
 117 be taken in event processing. In particular, a long running task, such
 118 as network io or computational intensive processing, executed on the
 119 event dispatching thread blocks the event dispatching thread from
 120 dispatching any other events. While the event dispatching thread is
 121 blocked the application is completely unresponsive to user
 122 input. Refer to {@link javax.swing.SwingWorker} for the preferred way to do such
 123 processing when working with Swing.
 124 <p>
 125 More information on this topic can be found in the
 126 <a href="http://docs.oracle.com/javase/tutorial/uiswing/">Swing tutorial</a>,
 127 in particular the section on
 128 <a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>.
 129 
 130 
 131 <H2>
 132 <a name="related">Related Documentation</a>
 133 </H2>
 134 <P>For overviews, tutorials, examples, guides, and other documentation, please see:
 135 
 136 <UL>
 137    <LI><A HREF="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html"
 138    target="_top">The Swing Connection</A>
 139    <LI><A HREF="http://docs.oracle.com/javase/tutorial/"
 140    target="_top">The Java Tutorial</A>
 141    <LI><A HREF="http://www.oracle.com/technetwork/java/javase/training/index.html"
 142    target="_top">Online Training</A> at the Java Developer Connection<font size=-2><sup>SM</sup></font>
 143    <LI><A HREF="http://www.oracle.com/technetwork/java/javase/tech/index-jsp-142216.html"
 144    target="_top">Java Foundation Classes (JFC)</A> home page
 145 </UL>
 146 
 147 @serial exclude
 148 
 149 </BODY>
 150 </HTML>
 151 
< prev index next >