What’s New in This Edition?

This second edition covers the latest developments in the Java 2 Standard Edition SDK 1.3 and 1.4. We’ve tried to highlight the changes from 1.2 in case you have to work with older releases for compatibility or political reasons.

For brevity’s sake, we refer to Java versions by their SDK version number, describing this or that feature as having been introduced in SDK 1.3 or 1.4. Earlier versions were called Java Development Kits, so in those cases we refer to JDK 1.1 or 1.2.

This new edition incorporated your feedback from the first edition! The first edition was too heavy on the documentation side for many readers. The Javadoc for the Swing packages continues to improve, and more and more people are familiar with the patterns of Java classes and methods. With those two facts in mind, we try to focus on the parts of the API that are interesting and useful rather than just including them because they exist. We added many new examples and improved the existing examples. This book is a true and thorough revision of the first edition, not a mere update.

As a quick reference to some of the changes you’ll find in the 1.3 and 1.4 releases of the SDK, Table P-1 and Table P-2 list any significant changes to components and briefly describe those changes. We detail these changes throughout the book as we discuss the particular components.

Table P-1. Swing changes in the Java 2 SDK 1.3

Component or feature

In chapter

Description of changes or additions

JTree

Chapter 17

Several new properties were added, including the click count to start editing and the selection path.

JTable

Chapter 15

Improved general performance and cell rendering. AbstractCellEditor is now the parent class of the DefaultCellEditor used by tables.

JSplitPane

Chapter 11

A new resizeWeight property was added, and the dividerLocationProperty is now bound.

JFileChooser

Chapter 12

You can now remove the Ok and Cancel buttons. A new property, acceptAllFileFilterUsed, was added.

JCheckBox

Chapter 5

Added new borderPaintedFlat property.

DefaultButtonModel

Chapter 5

Added new getGroup( ) method.

JInternalFrame

Chapter 9

Several fixes and newly public classes and methods. Internal frames are now invisible by default, and the default close operation is now DISPOSE_ON_CLOSE.

JTabbedPane

Chapter 11

Added new toolTipTextAt indexed property.

Text components

Chapter 19-Chapter 23

Several fixes applied. Several improvements in general HTML support via the HTMLEditorKit and related classes. (XHTML documents are still not supported.)

JViewport

Chapter 11

New scrollMode property added.

JComponent

Chapter 3

New print methods added: printComponent( ), printBorder( ), printChildren( ).

InputVerifier

Chapter 20

New class added.

Keyboard binding

Chapter 3, Appendix B

New keyboard binding mechanism added. New classes, InputMap and ActionMap, replace Keymap functionality.

Border s

Chapter 13

New LineBorder constructor to support rounded corners added.

Action s

Chapter 3, Chapter 5, Chapter 14

AbstractAction class was updated, and new constructors for JCheckBox, JRadioButton, JToggleButton, JMenu, JMenuItem, JCheckBoxMenuItem, and JRadioButtonMenuItem that use Action were added.

JToolBar

Chapter 14

Support for titling undocked toolbars added.

JPopupMenu

Chapter 14

Added new popupTrigger boolean property.

JFrame

Chapter 11

Added new EXIT_ON_CLOSE constant for use with the defaultCloseOperation property.

ListenerList

Chapter 27

Added getListeners( ) method to several model classes, including AbstractDocument, AbstractTableModel, AbstractListModel, DefaultButtonModel, DefaultTreeModel, and DefaultListSelectionModel.

Table P-2. Swing changes in the Java 2 SDK 1.4

Component or feature

In chapter

Description of changes or additions

JProgressBar

Chapter 6

Added support for indeterminate progress bars.

JSpinner

Chapter 7

Added new spinner class.

JFormattedTextField

Chapter 20

Added new formatted text field class that validates user input.

Focus

Chapter 3, Chapter 28

A new focus model and methodology was introduced. Several of the old-style focus methods and classes were deprecated as of 1.4.1.

Drag and Drop

Chapter 24

New architecture introduced, and dragEnabled and transferHandler properties added to several components.

Box

Chapter 11

Now descends from JComponent.

JButton

Chapter 5

More control over mnemonic underline location granted.

JComboBox

Chapter 7

Added PopupMenuListener and support for cell size prototyping.

JFileChooser

Chapter 12

Added support for modifying the properties of the Open button (such as its text and tooltip). Also added support for selecting multiple files. (The multiple file selection mode was introduced in the 1.2 release but was not implemented until 1.4.)

JInternalFrame

Chapter 9

Long titles are now truncated, and the title bar is rendered with a gradient.

Text components

Chapter 19-Chapter 23

Tooltip support was improved. HTML support, including accessibility in documents, was improved (XHTML is still not supported). New replace( ) method added to AbstractDocument.

JOptionPane

Chapter 10

New input dialog methods added.

JPopupMenu

Chapter 14

Now properly supports key bindings.

JTabbedPane

Chapter 11

Introduced scrollable tabs for panes with a large number of tabs. Mnemonic support for accessing tabs was also added.

JTree

Chapter 17

Null roots are now allowed, and first-letter keyboard navigation was added.

JList

Chapter 7

Items can now be arranged horizontally, and first-letter keyboard navigation was added.

SwingConstants

Chapter 27

New constants, NEXT and PREVIOUS, were added.

SwingUtilities

Chapter 27

New methods added, including calculateInnerArea( ) and applyComponentOrientation( )

LookAndFeel

Chapter 3, Chapter 26, Appendix B

General support for auditory cues was added. Access to Windows desktop properties was also added.

JComponent

Chapter 3

requestFocus( ) and requestFocusInWindow( ) methods are now public.

MouseWheelEventMouseWheelListener

Chapter 11

New event and listener for mouse wheels added.

JRootPane

Chapter 10

Look-and-feel can now supply window decoration.

JScrollBar

Chapter 6

Now properly overrides setUI( ).

JScrollPane

Chapter 11

Now supports mouse wheel events. (This support can be turned off.)

RepaintManager

Chapter 28

New method to return a VolatileImage.

SpringLayout

Chapter 11

New class (and supporting classes) added.

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.