This book gives a complete introduction to the entire Swing component set. Of course, it shows you how to use all of the components: how to display them on the screen, register for events, and get information from them. You’d expect that in any Swing book. This book goes much further. It goes into detail about the model-delegate architecture behind the components and discusses all of the data models. Understanding the models is essential when you’re working on an application that requires something significantly different from the components’ default behavior. For example, if you need a component that displays a different data type or one that structures data in some nonstandard way, you’ll need to work with the data models. This book also discusses how to write “accessible” user interfaces and how to create your own look-and-feel.
There are a few topics this book doesn’t cover, despite its girth.
We assume you know the Java language. For Swing, it’s particularly important to
have a good grasp of inner classes (both named and anonymous), which are
used by Swing itself and in our examples. We assume that you understand
the JDK 1.1 event model, Java’s mechanism for communicating between
asynchronous threads. Swing introduced many new event types, all of
which are discussed in this book, but we provide only an overview of the
event mechanism as a whole. We also assume that you understand the older
AWT components, particularly the Component
and Container
classes, which are superclasses of
the Swing’s JComponent
. We assume
that you understand the AWT layout managers, all of which are usable
within Swing applications. If you are new to Java, or would like a
review, you can find a complete discussion of these topics in the
Java AWT Reference by John Zukowski[1] or a solid introduction in Learning
Java by Pat Niemeyer and Jonathan Knudsen (both published by
O’Reilly). We do not assume that you know anything about other JFC
topics, like Java 2D—check out Java 2D by Jonathan
Knudsen for that; all the drawing and font manipulation in this book can
be done with AWT. (We do cover the JFC Accessibility API, which is
supported by every Swing component, as well as the drag-and-drop
facility, since this functionality is a requirement for modern user
interfaces.)
The major Swing classes fall into the following packages:
javax.accessibility
Classes that support accessibility for people who have difficulty using standard user interfaces. Covered in Chapter 25.
javax.swing
The bulk of the Swing components. Covered in Chapter 3-Chapter 14 and Chapter 27-Chapter 28.
javax.swing.border
Classes for drawing fancy borders around components. Covered in Chapter 13.
javax.swing.colorchooser
Classes providing support for the
JColorChooser
component. Covered in Chapter 12.javax.swing.event
javax.swing.filechooser
Classes providing support for the
JFileChooser
component. Covered in Chapter 12.javax.swing.plaf
Classes supporting the PLAF, including classes that implement the Metal and Multi L&Fs. (Implementations of the Windows and Motif L&Fs are packaged under
com.sun.java.swing.plaf
, and the Macintosh Aqua L&F is undercom.apple.mrj.swing
.) Covered in Chapter 26.javax.swing.table
Classes providing support for the
JTable
component (JTable
itself is injavax.swing
). Covered in Chapter 15 and Chapter 16.javax.swing.text
Classes providing support for the text components (such as
JTextField
; the components themselves are in thejavax.swing
package). Covered in Chapter 19-Chapter 23.javax.swing.text.html and javax.swing.text.rtf
“Editor kits” for working with HTML and Microsoft RTF documents. Covered in Chapter 23. The
text.html
package has a subpackage,parser
, which includes tools for parsing HTML.javax.swing.tree
Classes providing support for the
JTree
component (JTree
itself is injavax.swing
). Covered in Chapter 17.javax.swing.undo
Classes that implement undoable operations. Covered in Chapter 18.
[1] PDFs for the Java AWT Reference are available at this book’s web site, http://www.oreilly.com/catalog/jswing2.
Get Java Swing, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.