Table of Contents
Audience.
How to Use This Book.
Component Summaries.
Properties.
Swing Bugs.
Using the CD-ROM.
Swing and the JDK.
Code Examples from the Book.
Applets vs. Applications.
Conventions Used in This Book.
Acknowledgments.
I. SWING FUNDAMENTALS.
1. Introduction.
Swing History. Lightweight vs. Heavyweight Components. Swing
Components. AWT Replacement Components. Additional Swing
Components. J Components. Pluggable Look and Feel. An Overview of
the Swing Packages. Swing and the AWT. Peers vs. Pluggable Look and
Feel. Getting Started. Using Swing with Internet Browsers. Swing
Resources. Parting Shots.
2. Swing Basics.
Applets and Applications. Applets. The JApplet Class. Applications.
The JFrame Class. Applet/Application Combinations. GJApp. Mixing
Swing and AWT Components. Zorder. Swing Popup Menus. Scrolling.
Internal Frames. Swing and Threads. Ramifications of Swing’s
Single-Threaded Design. SwingUtilities invokeLater and
invokeAndWait Methods. Parting Shots.
3. Swing Component
Architecture.
Classic Model-View-Controller Architecture. Pluggable Views and
Controllers. View Updates. Swing MVC. Swing Components. A Static
Perspective. A Dynamic Perspective. Models. UI Delegates. Component
UI Scenarios. Listeners. Parting Shots.
4. The JComponent
Class.
An Overview of the JComponent Class. Borders. Accessibility
Support. Double Buffering. Debug Graphics. AutoScrolling. Tooltips.
Keystroke Handling and Client Properties. The JComponent Class.
Swing Components are AWT Containers. Minimum, Maximum, and
Preferred Sizes. Rendering JComponents. Custom Painting in Swing
Components. Overriding Paint Methods in AWT Components. Overriding
Paint Methods in Swing Components. Paint, Repaint, and Update
Methods. Validate, Invalidate, and Revalidate Methods. Opaque vs.
Transparent Components. Immediate Painting of Swing Components.
Double Buffering. Double Buffering in Custom Components. Debug
Graphics. Autoscrolling. Autoscrolling in Custom Components.
Tooltips. Tooltips Based on Mouse Position. Preferred Locations for
Tooltips. Customizing Tooltip Behavior. Customizing Tooltip Look
and Feel. Keystroke Handling. Client Properties. Focus Management.
Accessibility. Parting Shots.
5. Borders, Icons, and
Actions.
Borders. Borders and Insets. Swing Border Types. Opaque vs.
Transparent Borders. The Border Package. The Border Interface. The
AbstractBorder Class. The Border Factory — Sharing Borders.
Replacing Built- in Borders. Implementing Custom Borders. Icons.
Associating an Icon with a Component. Sharing Icons Among
Components. Image Icons. Animated Image Icons. Actions. Actions as
a Central Point of Control. Action Constants. Parting Shots.
6.
Utilities.
Timers. The Timer Class. Event Listener Lists. The
EventListenerList Class. Swing Utilities. Swing Constants.
BoxLayout and the Box Class. BoxLayout. The Box Class. Progress
Monitoring. ProgressMonitor. ProgressMonitorInputStream. Undo/Redo.
A Simple Undo/Redo Example. UndoableEditSupport. Compound Edits.
Undo Manager. State Edits. Parting Shots.
7. Pluggable Look and
Feel.
Look-and-Feel Architecture. Look and Feels. Look-and-Feel Defaults.
UI Manager. UI Resources. The Java Look and Feel. Client
Properties. Themes. Auxiliary UIs. Parting Shots.
II. SWING COMPONENTS.
8. Labels and Buttons.
JLabel and JButton. JLabel. JLabel Properties. JLabel Events.
JLabel Class Summaries. Buttons. Button Class Hierarchy. JButton.
JButton Properties. JButton Events. JButton Class Summaries. AWT
Compatibility. Parting Shots.
9. Toggle Buttons, Check Boxes, and
Radio Buttons.
JToggleButtons. JToggleButton Properties. JToggleButton Events.
JToggleButton Class Summaries. AWT Compatibility. Button Groups.
Check Boxes. JCheckBox Properties. JCheckBox Events. JCheckBox
Class Summaries. Radio Buttons. JRadioButton Properties.
JRadioButton Events. JRadioButton Class Summaries. AWT
Compatibility. Parting Shots.
10. Menus and Toolbars.
Menus, Menu Bars, and Toolbars. Menus and Popup Menus. JMenuItem.
Menu Item Accelerators and Mnemonics. JMenuItem Properties.
JMenuItem Events. JMenuItem Class Summaries. AWT Compatibility.
JCheckBoxMenuItem. JCheckBoxMenuItem Properties. JCheckBoxMenuItem
Events. JCheckBoxMenuItem Class Summaries. AWT Compatibility.
JRadioButtonMenuItem. JRadioButtonMenuItem Properties.
JRadioButtonMenuItem Events. JRadioButtonMenuItem Class Summaries.
AWT Compatibility. JMenu. Dynamically Modifying Menus. Pull-right
Menus. JMenu Properties. JMenu Events. JMenu Class Summaries. AWT
Compatibility. Menu Elements. Implementing the MenuElement
Interface. JPopupMenu. Popup Trigger. Light/Medium/HeavyWeight
Popup Menus. Popup Menu Invokers. JPopupMenu Properties. JPopupMenu
Events. JPopupMenu Class Summaries. AWT Compatibility. JMenuBar.
Menu Bar Menus and Components. JMenuBar Properties. JMenuBar
Events. JMenuBar Class Summaries. AWT Compatibilities. JToolBar.
Rollover Toolbars. Using Actions with Toolbars. Floating Toolbars.
Toolbar Buttons with Fixed- Location Tooltips. JToolBar Properties.
JToolBar Events. JToolBar Class Summaries. AWT Compatibility.
Parting Shots.
11. Progress Bars, Sliders, and
Separators.
JProgressBar. Progress Bars and Threads. JProgressBar Properties.
JProgressBar Events. JProgressBar Class Summaries. AWT
Compatibility. JSlider. Filled Sliders. Slider Tick Marks. Slider
Labels. Inverting Slider Values. Slider Extent. JSlider Properties.
JSlider Events. JSlider Class Summaries. AWT Compatibility.
JSeparator. Separators and Boxes. JSeparator Properties. JSeparator
Events. AWT Compatibility. Parting Shots.
12. Lightweight
Containers.
JPanel. JPanel Properties. JPanel Events. JPanel Class Summaries.
AWT Compatibility. JRootPane. The RootPaneContainer Interface.
Glass Panes. Content Panes. JRootPane Properties. JRootPane Events.
JRootPane Class Summaries. AWT Compatibility. JLayeredPane. Zorder
for Lightweight Components Revisited. Assigning Layers to
Components. Positioning Components in the Same Layers. Using the
Drag Layer. JLayeredPane Properties. JLayeredPane Class Summaries.
AWT Compatibility. JTabbedPane. Tab Placement. JTabbedPane
Properties. JTabbedPane Events. JTabbedPane Class Summaries.
JSPlitPane. JSplitPane Properties. JSplitPane Events. JSplitPane
Class Summaries. AWT Compatibility. Parting Shots.
13.
Scrolling.
JViewport. Dragging a Viewport’s View. Using the
scrollRectToVisibile Method. JViewport Properties. JViewport
Events. JViewport Class Summaries. AWT Compatibility. JScrollPane.
Scrollpane Headers. Scrollpane Corners. JScrollPane Properties.
JScrollPane Events. JScrollPane Class Summaries. AWT Compatibility.
The Scrollable Interface. JScrollBar. Manual Scrolling with Swing’s
JScrollBar Class. Block and Unit Increments. JScrollBar Properties.
JScrollBar Events. JScrollBar Class Summaries. AWT Compatibility.
Parting Shots.
14. Windows and Dialogs.
JWindow. JWindow Properties. JWindow Class Summaries. AWT
Compatibility. JDialog. JDialog Properties. JDialog Class
Summaries. AWT Compatibility. JOptionPane. Internal Frames.
Creating Dialogs with JOptionPane Static Methods. Message Dialogs.
Confirmation Dialogs. Input Dialogs. Option Dialogs. JOptionPane
Properties. JOptionPane Events. JOptionPane Class Summaries. AWT
Compatibility. Parting Shots.
15. Internal Frames and Desktop
Panes.
JInternalFrame. JInternalFrame Properties. JInternalFrame Events.
AWT Compatibility. JDesktopPane. JDesktopPane Properties.
JDesktopPane Events. JDesktopPane Class Summaries. AWT
Compatibility. DesktopManager. DesktopManager Class Summaries.
Parting Shots.
16. Choosers
JFileChooser. File Chooser Types. Accessory Components. Filtering
File Types. File Views. Multiple Selection. JFileChooser
Properties. JFileChooser Events. JFileChooser Class Summaries. AWT
Compatibility. JColorChooser. Displaying Color Choosers in Dialogs.
Customizing Color Choosers. JColorChooser Properties. JColorChooser
Events. JColorChooser Class Summaries. AWT Compatibility. Parting
Shots.
17. Lists.
List Models. AbstractListModel. DefaultListModel. List Selections.
List Cell Renderers. JList Properties. JList Events. JList Class
Summaries. AWT Compatibility. Parting Shots.
18. Combo
Boxes.
JComboBox vs. JList. The JComboBox Component. Combo Box Models.
ComboBoxModel. MutableComboBoxModel. DefaultComboBoxModel. Combo
Box Cell Renderers. Combo Box Key Selection Managers. Using the
Default Key Selection Managers. Custom Key Selection Managers.
Programmatic Key Selection. Combo Box Editors. JComboBox
Properties. JComboBox Events. JComboBox Class Summaries. AWT
Compatibility. Parting Shots.
19. Tables.
Tables and Scrolling. Block and Unit Increments. Table Models.
Table Data Models. The TableModel Interface. AbstractTableModel.
DefaultTableModel. Table Models and Default Renderers and Editors.
Table Columns. Column Resize Modes. Column Widths. Table Column
Models. The DefaultTableColumnModel Class. Column Margins. Hiding
Columns. Locking the Left-Hand Column. Table Selection. Rendering
and Editing. Using Table Cell Renderers and Editors. Table Cell
Rendering. Cell Editors. Table Cell Editors. Implementing the
TableCellEditor Interface. Table Rows. Row Height. Rendering by
Rows. Table Decorators. Sorting Decorators. Table Headers.
JTableHeader. Column Header Renderers and Header ToolTips. JTable
Properties. Table Events. Table Model Events. TableColumnModel
Events. List Selection Events. JTable Class Summaries. AWT
Compatibility. Parting Shots.
20. Trees.
Creating Trees. Tree Nodes. The TreeNode Interface. The
MutableTreeNode Interface. The DefaultMutableTreeNode Class. Tree
Paths. Tree Models. Default TreeModel. Tree Selection.
DefaultTreeSelectionModel. Tree Cell Rendering.
DefaultTreeCellRenderer. Metal Look and Feel. Root Nodes and Root
Handles. Tree Cell Editing. Extending DefaultCellEditor.
DefaultTreeCellEditor. Rendering and Editing: A Case Study. The
Test Class. The SelectableFile and FileNode Classes. The Renderers.
The Editors. JTree Properties. Tree Events. JTree Class Summaries.
AWT Compatibility. Parting Shots.
21. Text Fundamentals.
Swing Text Components. The Swing Text Package. Actions. Text
Actions. Actions and Editor Kits. Keymaps. Documents. Custom
Documents. Document Listeners. Carets and Highlighters. Carets.
Caret Listeners. Custom Carets. Highlighters. Undo/Redo.
JTextComponent. JTextComponent Properties. Parting Shots.
22.
Text Components.
JTextField. Horizontal Visibility and Scroll Offset. Laying Out
Text Fields. Validating Text Fields. JTextField Component Summary.
JTextField Properties. JTextField Events. JTextField Class
Summaries. AWT Compatibility. JPassword Field. JPasswordField
Component Summary. JPasswordField Properties. JPasswordField Class
Summary. JTextArea. JTextArea Component Summary. JTextArea
Properties. JTextArea Class Summaries. AWT Compatibility.
JEditorPane. JEditorPane Properties. JEditorPane Events.
JEditorPane Class Summaries. JTtextPane. Embedding Icons and
Components. Marking Content with Attributes. JTextPane Properties.
JTextPane Class Summaries. AWT Compatibility. Parting Shots.
23.
Customizing Text Components.
Overview. Attribute Sets and Style Constants. Custom Actions.
Views. Implementing Custom Views. Styles and Style Contexts.
Elements. Parting Shots.
Appendix A.
Class Diagrams. Class Diagram Legend. An Example Class
Diagram.
Appendix B.
Pluggable Look & Feel Constants.
Index.Promotional Information
Graphic Java 2 is quite simply the most comprehensive guide to
the Java Foundation Classes available. Written for experienced
programmers looking for thorough and detailed explanations of the
JFC libraries, Volume 2 covers all aspects of the swing framework.
Swing is the long-awaited successor to the AWT's heavyweight
components. It provides many components that AWT developers could
previously only dream about -- or purchase -- such as Tooltips,
tables, trees, sliders, a complete document framework, and more.
This book provides comprehensive coverage of the Swing framework,
the designs behind it, and the use of Swing components. Thousands
of experienced Java developers are ready to move beyond AWT's
limits. This book shows them how to do so. Together with Graphic
Java Volume 1 (AWT) and Volume 3 (2D API), it gives developers all
the tools they need to build professional, customizable
cross-platform applications that fully leverage the new Java
Foundation Classes -- and to deliver those applications fast.
(This is a 2 Volume set)
About the Author
David Gearywas lead engineer for the user interface
toolkit for JavaSoft's Java Management API. He has been developing
GUIs and using object-oriented technology since 1984, including
C++, Smalltalk, Eiffel, Objective-C and now Java. He is currently
an independent Java consultant.