< prev index next >

src/java.desktop/share/classes/javax/swing/package-info.java

Print this page




  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /**
  27  * Provides a set of &quot;lightweight&quot; (all-Java language) components
  28  * that, to the maximum degree possible, work the same on all platforms. For a
  29  * programmer's guide to using these components, see
  30  * <a href="http://docs.oracle.com/javase/tutorial/uiswing/index.html"
  31  * target="_top">Creating a GUI with JFC/Swing</a>, a trail in
  32  * <em>The Java Tutorial</em>. For other resources, see
  33  * <a href="#related">Related Documentation</a>.
  34  *
  35  * <h2><a name="threading">Swing's Threading Policy</a></h2>
  36  * In general Swing is not thread safe. All Swing components and related
  37  * classes, unless otherwise documented, must be accessed on the event
  38  * dispatching thread.
  39  * <p>
  40  * Typical Swing applications do processing in response to an event generated
  41  * from a user gesture. For example, clicking on a {@code JButton} notifies all
  42  * {@code ActionListeners} added to the {@code JButton}. As all events generated
  43  * from a user gesture are dispatched on the event dispatching thread, most
  44  * developers are not impacted by the restriction.
  45  * <p>
  46  * Where the impact lies, however, is in constructing and showing a Swing
  47  * application. Calls to an application's {@code main} method, or methods in
  48  * {@code Applet}, are not invoked on the event dispatching thread. As such,
  49  * care must be taken to transfer control to the event dispatching thread when
  50  * constructing and showing an application or applet. The preferred way to
  51  * transfer control and begin working with Swing is to use {@code invokeLater}.
  52  * The {@code invokeLater} method schedules a {@code Runnable} to be processed
  53  * on the event dispatching thread. The following two examples work equally well
  54  * for transferring control and starting up a Swing application:
  55  * <pre>


  93  * {@code TableModel} should only be modified on the event dispatching thread.
  94  * If you modify the model on a separate thread you run the risk of exceptions
  95  * and possible display corruption.
  96  * <p>
  97  * As all events are delivered on the event dispatching thread, care must be
  98  * taken in event processing. In particular, a long running task, such as
  99  * network io or computational intensive processing, executed on the event
 100  * dispatching thread blocks the event dispatching thread from dispatching any
 101  * other events. While the event dispatching thread is blocked the application
 102  * is completely unresponsive to user input. Refer to
 103  * {@link javax.swing.SwingWorker} for the preferred way to do such processing
 104  * when working with Swing.
 105  * <p>
 106  * More information on this topic can be found in the
 107  * <a href="http://docs.oracle.com/javase/tutorial/uiswing/">Swing tutorial</a>,
 108  * in particular the section on
 109  * <a
 110  * href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">
 111  * Concurrency in Swing</a>.
 112  *
 113  * <h2><a name="related">Related Documentation</a></h2>
 114  * For overviews, tutorials, examples, guides, and other documentation,
 115  * please see:
 116  * <ul>
 117  *     <li><a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html"
 118  *     target="_top">The Swing Connection</a></li>
 119  *     <li><a href="http://docs.oracle.com/javase/tutorial/"
 120  *     target="_top">The Java Tutorial</a></li>
 121  *     <li><a href="http://www.oracle.com/technetwork/java/javase/training/index.html"
 122  *     target="_top">Online Training</a>
 123  *     at the Java Developer Connection <sup>SM</sup></li>
 124  *     <li><a href="http://www.oracle.com/technetwork/java/javase/tech/index-jsp-142216.html"
 125  *     target="_top">Java Foundation Classes (JFC)</a> home page</li>
 126  * </ul>
 127  *
 128  * @serial exclude
 129  */
 130 package javax.swing;


  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /**
  27  * Provides a set of &quot;lightweight&quot; (all-Java language) components
  28  * that, to the maximum degree possible, work the same on all platforms. For a
  29  * programmer's guide to using these components, see
  30  * <a href="http://docs.oracle.com/javase/tutorial/uiswing/index.html"
  31  * target="_top">Creating a GUI with JFC/Swing</a>, a trail in
  32  * <em>The Java Tutorial</em>. For other resources, see
  33  * <a href="#related">Related Documentation</a>.
  34  *
  35  * <h2><a id="threading">Swing's Threading Policy</a></h2>
  36  * In general Swing is not thread safe. All Swing components and related
  37  * classes, unless otherwise documented, must be accessed on the event
  38  * dispatching thread.
  39  * <p>
  40  * Typical Swing applications do processing in response to an event generated
  41  * from a user gesture. For example, clicking on a {@code JButton} notifies all
  42  * {@code ActionListeners} added to the {@code JButton}. As all events generated
  43  * from a user gesture are dispatched on the event dispatching thread, most
  44  * developers are not impacted by the restriction.
  45  * <p>
  46  * Where the impact lies, however, is in constructing and showing a Swing
  47  * application. Calls to an application's {@code main} method, or methods in
  48  * {@code Applet}, are not invoked on the event dispatching thread. As such,
  49  * care must be taken to transfer control to the event dispatching thread when
  50  * constructing and showing an application or applet. The preferred way to
  51  * transfer control and begin working with Swing is to use {@code invokeLater}.
  52  * The {@code invokeLater} method schedules a {@code Runnable} to be processed
  53  * on the event dispatching thread. The following two examples work equally well
  54  * for transferring control and starting up a Swing application:
  55  * <pre>


  93  * {@code TableModel} should only be modified on the event dispatching thread.
  94  * If you modify the model on a separate thread you run the risk of exceptions
  95  * and possible display corruption.
  96  * <p>
  97  * As all events are delivered on the event dispatching thread, care must be
  98  * taken in event processing. In particular, a long running task, such as
  99  * network io or computational intensive processing, executed on the event
 100  * dispatching thread blocks the event dispatching thread from dispatching any
 101  * other events. While the event dispatching thread is blocked the application
 102  * is completely unresponsive to user input. Refer to
 103  * {@link javax.swing.SwingWorker} for the preferred way to do such processing
 104  * when working with Swing.
 105  * <p>
 106  * More information on this topic can be found in the
 107  * <a href="http://docs.oracle.com/javase/tutorial/uiswing/">Swing tutorial</a>,
 108  * in particular the section on
 109  * <a
 110  * href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">
 111  * Concurrency in Swing</a>.
 112  *
 113  * <h2><a id="related">Related Documentation</a></h2>
 114  * For overviews, tutorials, examples, guides, and other documentation,
 115  * please see:
 116  * <ul>
 117  *     <li><a href="http://www.oracle.com/technetwork/java/javase/tech/articles-jsp-139072.html"
 118  *     target="_top">The Swing Connection</a></li>
 119  *     <li><a href="http://docs.oracle.com/javase/tutorial/"
 120  *     target="_top">The Java Tutorial</a></li>
 121  *     <li><a href="http://www.oracle.com/technetwork/java/javase/training/index.html"
 122  *     target="_top">Online Training</a>
 123  *     at the Java Developer Connection <sup>SM</sup></li>
 124  *     <li><a href="http://www.oracle.com/technetwork/java/javase/tech/index-jsp-142216.html"
 125  *     target="_top">Java Foundation Classes (JFC)</a> home page</li>
 126  * </ul>
 127  *
 128  * @serial exclude
 129  */
 130 package javax.swing;
< prev index next >