Overview of the Swing API

The Swing package is part of the Java™ Foundation Classes (JFC) in the Java platform. The JFC encompasses a group of features to help people build GUIs; Swing provides all the components from buttons to split panes and tables.

The Swing package was first available as an add-on to JDK 1.1. Prior to the introduction of the Swing package, the Abstract Window Toolkit (AWT) components provided all the UI components in the JDK 1.0 and 1.1 platforms. Although the Java 2 Platform still supports the AWT components, we strongly encourage you to use Swing components instead. You can identify Swing components because their names start with J. The AWT button class, for example, is named Button, whereas the Swing button class is named JButton. In addition, the AWT components are in the java.awt package, whereas the Swing components are in the javax.swing package.

As a rule, programs should not use "heavyweight" AWT components alongside Swing components. Heavyweight components include all the ready-to-use AWT components, such as Menu and ScrollPane, and all components that inherit from the AWT Canvas and Panel classes. When Swing components (and all other "lightweight" components) overlap with heavyweight components, the heavyweight component is always painted on top. [1]

[1] To learn more about the differences between Swing components and AWT components, see the section "Converting to Swing" in the book The JFC Swing Tutorial. This section is also available on this book's CD and online at http://java.sun.com/docs/books/tutorial/uiswing/converting/index.html.

Compiling and Running Swing Programs

To compile and run your Swing programs, we recommend that you either use the latest release of the Java 2 Platform downloaded from http://java.sun.com or use the Java 2 Platform v 1.3 included on this book's CD. You can run Swing applets in any browser that has the appropriate version of Java™ Plug-in installed. [2] Swing applets are covered in Appendix B, Internet-Ready Applets (page 407).

[2] The Java Plug-in is included as part of the JRE 1.3 Win32 release. For more information about the Plugin on other platforms, see http://java.sun.com/products/plugin/index.html

Getting Started

Object-Oriented Programming Concepts

Language Basics

Object Basics and Simple Data Objects

Classes and Inheritance

Interfaces and Packages

Handling Errors Using Exceptions

Threads: Doing Two or More Tasks at Once

I/O: Reading and Writing

User Interfaces That Swing

Appendix A. Common Problems and Their Solutions

Appendix B. Internet-Ready Applets

Appendix C. Collections

Appendix D. Deprecated Thread Methods

Appendix E. Reference



The Java Tutorial(c) A Short Course on the Basics
The Java Tutorial: A Short Course on the Basics, 4th Edition
ISBN: 0321334205
EAN: 2147483647
Year: 2002
Pages: 125

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net