Swing: An Overview

Note: An updated and expanded version of this material appears in Core Web Programming 2nd Edition. All source code (plus sample chapters) is available at http://www.corewebprogramming.com/.

1. Main New Features

2. Swing is Standard in Java 2 (aka Java 1.2)

3. Separate Swing package can be added to Java 1.1.

4. Getting More Info.

See the on-line Java 2 API or the books in the Swing/JFC section of http://www.apl.jhu.edu/~hall/java/Java-Books.html.

5. Components are named JXxx.

E.g. JFrame, JPanel, JApplet, JDialog, JButton, etc.

6. There is an almost-equivalent Swing component for most AWT components.

7. Do drawing in paintComponent, not paint.

8. Instead of adding components directly to frames or applets, use the content pane

9. Model-View-Controller architecture lets you change the internal data representation for lists, trees, tables, etc.

10. Swing was in the com.sun.java.swing package in beta releases of 1.2. Switched to javax.swing in 1.2 final.

11. Default "look and feel" is a Java-specific one.

12. Mixing AWT and Swing is doomed.

AWT components are always on top, and z-ordering problems catch you in many unexpected ways. Stick with the AWT or move completely to Swing.


This page is part of my Quick Swing Tutorial for AWT Programmers. © 1999 Marty Hall. All source code freely available for unrestricted use. Created for for work in the Research and Technology Development Center of the Johns Hopkins University Applied Physics Lab, for courses in the Johns Hopkins Part-Time MS Program in Computer Science, and for various industry seminars and Java short courses.