Cover image for Java Swing, 2nd Edition

Book description

Swing is a fully-featured user interface development kit for Java applications. Building on the foundations of the Abstract Window Toolkit (AWT), Swing enables cross-platform applications to use any of several pluggable look-and-feels. Swing developers can take advantage of its rich, flexible features and modular components, building elegant user interfaces with very little code. This second edition of Java Swing thoroughly covers all the features available in Java 2 SDK 1.3 and 1.4. More than simply a reference, this new edition takes a practical approach. It is a book by developers for developers, with hundreds of useful examples, from beginning level to advanced, covering every component available in Swing. All these features mean that there's a lot to learn. Even setting aside its platform flexibility, Swing compares favorably with any widely available user interface toolkit--it has great depth. Swing makes it easy to do simple things but is powerful enough to create complex, intricate interfaces. Java Swing, 2nd edition includes :

  • A new chapter on Drag and Drop

  • Accessibility features for creating a user interface meeting the needs of all users

  • Coverage of the improved key binding infrastructure introduced in SDK 1.3

  • A new chapter on JFormattedTextField and input validation

  • Mac OS X coverage and examples

  • Coverage of the improved focus system introduced in SDK 1.4

  • Pluggable Look-and-Feel coverage

  • Coverage of the new layout manager, SpringLayout, from SDK 1.4

  • Properties tables that summarize important features of each component

  • Coverage of the 1.4 Spinner component

  • Details about using HTML in components

  • A new appendix listing bound actions for each component

  • A supporting web site with utilities, examples, and supplemental materials

Whether you're a seasoned Java developer or just trying to find out what Java can do, you'll find Java Swing, 2nd edition an indispensable guide.

Table of Contents

  1. Java Swing, 2nd Edition
  2. A Note Regarding Supplemental Files
  3. Preface
    1. What This Book Covers
    2. What’s New in This Edition?
    3. On the Web Site
    4. Conventions
      1. Properties Tables
      2. Class Diagrams
    5. How to Contact Us
    6. Acknowledgments
      1. Marc Loy
      2. Brian Cole
      3. James Elliott
  4. 1. Introducing Swing
    1. 1.1. What Is Swing?
      1. 1.1.1. What Are the Java Foundation Classes?
      2. 1.1.2. Is Swing a Replacement for AWT?
      3. 1.1.3. Rethinking the AWT
    2. 1.2. Swing Features
      1. 1.2.1. Pluggable Look-and-Feels
      2. 1.2.2. Lightweight Components
      3. 1.2.3. Additional Features
      4. 1.2.4. How Can I Use Swing?
    3. 1.3. Swing Packages and Classes
      1. 1.3.1. Class Hierarchy
    4. 1.4. The Model-View-Controller Architecture
      1. 1.4.1. MVC Interaction
      2. 1.4.2. MVC in Swing
    5. 1.5. Working with Swing
      1. 1.5.1. Multithreading
      2. 1.5.2. The Z-Order Caveat: Lightweight and Heavyweight Components
    6. 1.6. The Swing Set Demo
    7. 1.7. Reading This Book
  5. 2. Jump-Starting a Swing Application
    1. 2.1. Upgrading Your AWT Programs
    2. 2.2. A Simple AWT Application
    3. 2.3. Including Your First Swing Component
    4. 2.4. Beyond Buttons
    5. 2.5. What Is an Internal Frame?
    6. 2.6. A Bigger Application
  6. 3. Swing Component Basics
    1. 3.1. Understanding Actions
      1. 3.1.1. Actions and Containers
      2. 3.1.2. The Action Interface
        1. 3.1.2.1. Property
        2. 3.1.2.2. Methods
        3. 3.1.2.3. Events
      3. 3.1.3. The AbstractAction Class
        1. 3.1.3.1. Properties
        2. 3.1.3.2. Events
        3. 3.1.3.3. Constructors
        4. 3.1.3.4. Methods
        5. 3.1.3.5. Using an Action
    2. 3.2. Graphical Interface Events
    3. 3.3. Graphics Environments
      1. 3.3.1. Headless Modes
    4. 3.4. Sending Change Events in Swing
      1. 3.4.1. The ChangeEvent Class
        1. 3.4.1.1. Constructor
      2. 3.4.2. The ChangeListener Interface
        1. 3.4.2.1. Method
    5. 3.5. The JComponent Class
      1. 3.5.1. Inherited Properties
      2. 3.5.2. Common Methods
      3. 3.5.3. JComponent Properties
        1. 3.5.3.1. New properties in the 1.3 and 1.4 SDKs
      4. 3.5.4. UI Delegates and UIClassIDs
      5. 3.5.5. Invalidating and Repainting
        1. 3.5.5.1. The paint( ) method and opaqueness
      6. 3.5.6. Position, Size, and Alignment
      7. 3.5.7. Adding Borders
      8. 3.5.8. Working with Tooltips
      9. 3.5.9. Client Properties
      10. 3.5.10. Double Buffering
      11. 3.5.11. Serialization
      12. 3.5.12. The DebugGraphics Class
      13. 3.5.13. Focus and Focus Cycle Methods
      14. 3.5.14. Keyboard Events
      15. 3.5.15. Accessibility
      16. 3.5.16. Events
        1. 3.5.16.1. Event methods
      17. 3.5.17. Constructor
      18. 3.5.18. Graphics Methods
      19. 3.5.19. Focus Methods
      20. 3.5.20. Tooltip Methods
      21. 3.5.21. Client Properties Methods
      22. 3.5.22. Miscellaneous Methods
    6. 3.6. Responding to Keyboard Input
      1. 3.6.1. The InputMap Class
        1. 3.6.1.1. Property
        2. 3.6.1.2. Constructor
        3. 3.6.1.3. Methods
      2. 3.6.2. The ActionMap Class
        1. 3.6.2.1. Property
        2. 3.6.2.2. Constructor
        3. 3.6.2.3. Methods
  7. 4. Labels and Icons
    1. 4.1. Labels
      1. 4.1.1. Properties
        1. 4.1.1.1. displayedMnemonic and labelFor properties
      2. 4.1.2. Alignment
    2. 4.2. Working with Images
      1. 4.2.1. Events
      2. 4.2.2. Constant
      3. 4.2.3. Constructors
      4. 4.2.4. Public Method
    3. 4.3. Support for HTML
    4. 4.4. Icons
      1. 4.4.1. Properties
      2. 4.4.2. Method
    5. 4.5. Implementing Your Own Icons
    6. 4.6. Dynamic Icons
    7. 4.7. The ImageIcon Class
      1. 4.7.1. Properties
      2. 4.7.2. Serialization
      3. 4.7.3. Constructors
      4. 4.7.4. User Interface Method
  8. 5. Buttons
    1. 5.1. The ButtonModel Interface
      1. 5.1.1. Properties
      2. 5.1.2. Events
    2. 5.2. The DefaultButtonModel Class
      1. 5.2.1. Properties
      2. 5.2.2. Events
      3. 5.2.3. Constants
      4. 5.2.4. Constructor
    3. 5.3. The AbstractButton Class
      1. 5.3.1. Properties
      2. 5.3.2. Events
      3. 5.3.3. Constants
      4. 5.3.4. Public Methods
      5. 5.3.5. Action Configuration Methods
    4. 5.4. The JButton Class
      1. 5.4.1. Properties
      2. 5.4.2. Using the Default Button
      3. 5.4.3. Events
      4. 5.4.4. Constructors
      5. 5.4.5. Using Actions
      6. 5.4.6. Fancy Buttons
    5. 5.5. The JToggleButton Class
      1. 5.5.1. Properties
      2. 5.5.2. Events
      3. 5.5.3. Constructors
    6. 5.6. The JToggleButton.ToggleButtonModel Class
      1. 5.6.1. Properties
    7. 5.7. The JCheckBox Class
      1. 5.7.1. Properties
      2. 5.7.2. Events
      3. 5.7.3. Constant
      4. 5.7.4. Constructors
    8. 5.8. The JRadioButton Class
      1. 5.8.1. Properties
        1. 5.8.1.1. Events
      2. 5.8.2. Constructors
      3. 5.8.3. Opaque JRadioButtons and JCheckBoxes
    9. 5.9. The ButtonGroup Class
      1. 5.9.1. Properties
      2. 5.9.2. Voting with a Button Group
      3. 5.9.3. Constructor
      4. 5.9.4. Methods
  9. 6. Bounded-Range Components
    1. 6.1. The Bounded-Range Model
      1. 6.1.1. Properties
      2. 6.1.2. Events
      3. 6.1.3. Method
      4. 6.1.4. The DefaultBoundedRangeModel Class
        1. 6.1.4.1. Properties
        2. 6.1.4.2. Events
        3. 6.1.4.3. Constructors
        4. 6.1.4.4. Working with the bounded-range model
    2. 6.2. The JScrollBar Class
      1. 6.2.1. Properties
      2. 6.2.2. Events
      3. 6.2.3. Constructors
      4. 6.2.4. Miscellaneous
      5. 6.2.5. Handling Events from a Scrollbar
    3. 6.3. The JSlider Class
      1. 6.3.1. Properties
        1. 6.3.1.1. Client properties
      2. 6.3.2. Events
      3. 6.3.3. Constructors
      4. 6.3.4. Labels
      5. 6.3.5. Miscellaneous
      6. 6.3.6. Creating a Slider
    4. 6.4. The JProgressBar Class
      1. 6.4.1. Properties
      2. 6.4.2. Events
      3. 6.4.3. Constructors
      4. 6.4.4. Working with Progress Bars
    5. 6.5. Monitoring Progress
      1. 6.5.1. The ProgressMonitor Class
        1. 6.5.1.1. Properties
          1. 6.5.1.1.1. UIManager properties
        2. 6.5.1.2. Constructor
        3. 6.5.1.3. Miscellaneous
        4. 6.5.1.4. Using a progress monitor
      2. 6.5.2. The ProgressMonitorInputStream
        1. 6.5.2.1. Property
        2. 6.5.2.2. Constructor
        3. 6.5.2.3. InputStream methods
        4. 6.5.2.4. Using a ProgressMonitorInputStream
  10. 7. Lists, Combo Boxes, and Spinners
    1. 7.1. Lists
      1. 7.1.1. Anatomy of a Swing List
      2. 7.1.2. Where to Go from Here?
    2. 7.2. Representing List Data
      1. 7.2.1. The ListModel Interface
        1. 7.2.1.1. Properties
        2. 7.2.1.2. Events
      2. 7.2.2. The AbstractListModel Class
        1. 7.2.2.1. Methods
      3. 7.2.3. The DefaultListModel Class
        1. 7.2.3.1. Properties
        2. 7.2.3.2. Constructor
        3. 7.2.3.3. Methods
        4. 7.2.3.4. A JList with changing contents
      4. 7.2.4. ListDataEvent
        1. 7.2.4.1. Properties
        2. 7.2.4.2. Constants
        3. 7.2.4.3. Constructor
        4. 7.2.4.4. Method
      5. 7.2.5. The ListDataListener Interface
        1. 7.2.5.1. Methods
    3. 7.3. Handling Selections
      1. 7.3.1. The ListSelectionModel Interface
        1. 7.3.1.1. Properties
        2. 7.3.1.2. Constants
        3. 7.3.1.3. Methods
        4. 7.3.1.4. Events
      2. 7.3.2. The DefaultListSelectionModel Class
        1. 7.3.2.1. Properties
        2. 7.3.2.2. Events
        3. 7.3.2.3. Constructor
        4. 7.3.2.4. Method
        5. 7.3.2.5. Working with the ListSelectionModel
      3. 7.3.3. ListSelectionEvent
        1. 7.3.3.1. Properties
        2. 7.3.3.2. Constructor
        3. 7.3.3.3. Methods
      4. 7.3.4. ListSelectionListener
        1. 7.3.4.1. Listening for ListSelectionEvents
    4. 7.4. Displaying Cell Elements
      1. 7.4.1. The ListCellRenderer Interface
      2. 7.4.2. Implementing a Cell Renderer
      3. 7.4.3. The DefaultListCellRenderer Class
    5. 7.5. The JList Class
      1. 7.5.1. Properties
      2. 7.5.2. Constants
      3. 7.5.3. Constructors
      4. 7.5.4. Miscellaneous
      5. 7.5.5. Selection Model
      6. 7.5.6. Scrolling
      7. 7.5.7. Data Model
      8. 7.5.8. User Interface
      9. 7.5.9. Events
      10. 7.5.10. The Java Books Example
    6. 7.6. Combo Boxes
      1. 7.6.1. The ComboBoxModel Interface
        1. 7.6.1.1. Property
        2. 7.6.1.2. Events
      2. 7.6.2. The MutableComboBoxModel Interface
      3. 7.6.3. The DefaultComboBoxModel Class
        1. 7.6.3.1. Constructors
        2. 7.6.3.2. Methods
        3. 7.6.3.3. Event
      4. 7.6.4. ComboBoxEditor
        1. 7.6.4.1. Properties
        2. 7.6.4.2. Events
        3. 7.6.4.3. Method
      5. 7.6.5. Implementing a Custom Editor
    7. 7.7. The JComboBox Class
      1. 7.7.1. The Key Selection Manager
        1. 7.7.1.1. Properties
        2. 7.7.1.2. Events
        3. 7.7.1.3. Constructors
        4. 7.7.1.4. Methods
        5. 7.7.1.5. List methods
        6. 7.7.1.6. Key selection
        7. 7.7.1.7. Internal methods
      2. 7.7.2. Java Books Revisited
    8. 7.8. Spinners
      1. 7.8.1. Properties
      2. 7.8.2. Events
      3. 7.8.3. Constructors
      4. 7.8.4. Editing Methods
      5. 7.8.5. Simple Spinners
    9. 7.9. Spinner Models
      1. 7.9.1. The SpinnerModel Interface
        1. 7.9.1.1. Properties
        2. 7.9.1.2. Events
      2. 7.9.2. The AbstractSpinnerModel Class
      3. 7.9.3. The SpinnerDateModel
        1. 7.9.3.1. Properties
        2. 7.9.3.2. Constructors
      4. 7.9.4. The SpinnerListModel Class
        1. 7.9.4.1. Properties
        2. 7.9.4.2. Constructors
      5. 7.9.5. The SpinnerNumberModel Class
        1. 7.9.5.1. Properties
        2. 7.9.5.2. Constructors
      6. 7.9.6. A Custom Model: Rollover Lists
    10. 7.10. Spinner Editors
      1. 7.10.1. DefaultEditor
        1. 7.10.1.1. Constructors
        2. 7.10.1.2. Properties
        3. 7.10.1.3. Editing methods
      2. 7.10.2. DateEditor
        1. 7.10.2.1. Constructors
        2. 7.10.2.2. Properties
      3. 7.10.3. ListEditor
        1. 7.10.3.1. Constructor
        2. 7.10.3.2. Property
      4. 7.10.4. NumberEditor
        1. 7.10.4.1. Constructors
        2. 7.10.4.2. Properties
      5. 7.10.5. A Custom Editor
  11. 8. Swing Containers
    1. 8.1. A Simple Container
      1. 8.1.1. The JPanel Class
        1. 8.1.1.1. Properties
        2. 8.1.1.2. Constructors
        3. 8.1.1.3. Opacity
    2. 8.2. The Root Pane
      1. 8.2.1. The JRootPane Class
      2. 8.2.2. The Glass Pane
      3. 8.2.3. Avoiding Unnecessary Layers
        1. 8.2.3.1. Properties
      4. 8.2.4. Revalidate
        1. 8.2.4.1. Constructor
      5. 8.2.5. The RootPaneContainer Interface
        1. 8.2.5.1. Properties
      6. 8.2.6. The JLayeredPane Class
        1. 8.2.6.1. Properties
        2. 8.2.6.2. Constants
        3. 8.2.6.3. Constructor
      7. 8.2.7. Adding Components to Layers
        1. 8.2.7.1. Layer management methods
        2. 8.2.7.2. Static methods
    3. 8.3. Basic RootPaneContainers
      1. 8.3.1. The WindowConstants Interface
        1. 8.3.1.1. Constants
    4. 8.4. The JFrame Class
      1. 8.4.1. Properties
      2. 8.4.2. Constructors
      3. 8.4.3. Protected Methods
      4. 8.4.4. Exiting Frames
    5. 8.5. The JWindow Class
      1. 8.5.1. Properties
      2. 8.5.2. Constructors
    6. 8.6. The JApplet Class
      1. 8.6.1. Hiding the Warning Message
      2. 8.6.2. Threading Issues
      3. 8.6.3. Properties
      4. 8.6.4. Constructor
      5. 8.6.5. User Interface Method
  12. 9. Internal Frames
    1. 9.1. Simulating a Desktop
      1. 9.1.1. Overview
    2. 9.2. The JInternalFrame Class
      1. 9.2.1. Properties
      2. 9.2.2. Events
      3. 9.2.3. Constants
      4. 9.2.4. Constructors
      5. 9.2.5. JLayeredPane Methods
      6. 9.2.6. Miscellaneous Public Methods
      7. 9.2.7. Use of the Glass Pane
      8. 9.2.8. The Metal Look-and-Feel JInternalFrame.isPalette Client Property
      9. 9.2.9. The JInternalFrame.JDesktopIcon Class
      10. 9.2.10. The InternalFrameEvent Class
        1. 9.2.10.1. Constants
      11. 9.2.11. The InternalFrameListener Interface
        1. 9.2.11.1. Methods
      12. 9.2.12. The InternalFrameAdapter Class
        1. 9.2.12.1. Methods
    3. 9.3. The JDesktopPane Class
      1. 9.3.1. Properties
      2. 9.3.2. Constructor
      3. 9.3.3. Methods
    4. 9.4. The DesktopManager Interface
      1. 9.4.1. Methods
      2. 9.4.2. The DefaultDesktopManager Class
        1. 9.4.2.1. Methods
        2. 9.4.2.2. Protected methods
    5. 9.5. Building a Desktop
      1. 9.5.1. Setting Things Up
      2. 9.5.2. Adding Frames to the Desktop
      3. 9.5.3. Veto Power
        1. 9.5.3.1. Bounding the frames
      4. 9.5.4. Moving Things Around
      5. 9.5.5. Source Code
  13. 10. Swing Dialogs
    1. 10.1. The JDialog Class
      1. 10.1.1. Properties
      2. 10.1.2. Constructors
      3. 10.1.3. Public Methods
    2. 10.2. The JOptionPane Class
      1. 10.2.1. Properties
      2. 10.2.2. JOptionPane Structure
    3. 10.3. Using JOptionPane
      1. 10.3.1. Events
      2. 10.3.2. Constants
      3. 10.3.3. Four Dialog Types
      4. 10.3.4. Constructors
      5. 10.3.5. Static Dialog Display Methods
      6. 10.3.6. Dialog Creation Method Parameters
    4. 10.4. Simple Examples
    5. 10.5. Getting the Results
    6. 10.6. A Comparison: Constructors Versus Static Methods
      1. 10.6.1. Nonstatic Methods
      2. 10.6.2. Miscellaneous Static Methods
    7. 10.7. Using Internal Frame Dialogs with JDesktopPane
  14. 11. Specialty Panes and Layout Managers
    1. 11.1. The JSplitPane Class
      1. 11.1.1. Properties
      2. 11.1.2. Constants
      3. 11.1.3. Constructors
      4. 11.1.4. Control Methods
      5. 11.1.5. Minimum and Preferred Sizes
    2. 11.2. The JScrollPane Class
      1. 11.2.1. Properties
      2. 11.2.2. Constructors
      3. 11.2.3. Pane Component Methods
      4. 11.2.4. Headers and Corners
      5. 11.2.5. The Scrollable Interface
        1. 11.2.5.1. Increment methods
        2. 11.2.5.2. Viewport dimension methods
        3. 11.2.5.3. The JScrollPane.ScrollBar class
      6. 11.2.6. The ScrollPaneLayout Class
        1. 11.2.6.1. Properties
      7. 11.2.7. JViewport
        1. 11.2.7.1. Properties
        2. 11.2.7.2. Events
        3. 11.2.7.3. Constructor
        4. 11.2.7.4. Useful methods
      8. 11.2.8. The ViewportLayout Class
    3. 11.3. The JTabbedPane Class
      1. 11.3.1. Constants
      2. 11.3.2. Properties
      3. 11.3.3. Events
      4. 11.3.4. Constructors
      5. 11.3.5. Tab Methods
      6. 11.3.6. Miscellaneous Methods
    4. 11.4. Layout Managers
      1. 11.4.1. The Box Class
        1. 11.4.1.1. Properties
        2. 11.4.1.2. Constructor
        3. 11.4.1.3. Creation method
        4. 11.4.1.4. Spacing and resizing methods
      2. 11.4.2. The Box.Filler Class
        1. 11.4.2.1. Properties
        2. 11.4.2.2. Constructor
        3. 11.4.2.3. Shape method
      3. 11.4.3. The BoxLayout Class
        1. 11.4.3.1. Constants
        2. 11.4.3.2. Constructor
        3. 11.4.3.3. Box alignments
      4. 11.4.4. The OverlayLayout Class
        1. 11.4.4.1. Constructor
      5. 11.4.5. An OverlayLayout Example
      6. 11.4.6. The SizeRequirements Class
        1. 11.4.6.1. Fields
        2. 11.4.6.2. Constructors
        3. 11.4.6.3. Methods
    5. 11.5. The SpringLayout Class
      1. 11.5.1. Springs and Struts
      2. 11.5.2. Constants
      3. 11.5.3. Constructor
      4. 11.5.4. Constraint Methods
      5. 11.5.5. The SpringLayout.Constraints Inner Class
        1. 11.5.5.1. Properties
        2. 11.5.5.2. Constructors
      6. 11.5.6. The Spring Class
        1. 11.5.6.1. Constant
        2. 11.5.6.2. Properties
        3. 11.5.6.3. Creating springs
        4. 11.5.6.4. Manipulation methods
        5. 11.5.6.5. Other operations
      7. 11.5.7. Arranging Components
      8. 11.5.8. Custom Springs
    6. 11.6. Other Panes
  15. 12. Chooser Dialogs
    1. 12.1. The JFileChooser Class
      1. 12.1.1. Properties
      2. 12.1.2. File Chooser Accessories
      3. 12.1.3. Events
      4. 12.1.4. Constants
      5. 12.1.5. Constructors
      6. 12.1.6. FileFilter Methods
      7. 12.1.7. File and Directory Methods
      8. 12.1.8. Dialog Methods
    2. 12.2. The File Chooser Package
      1. 12.2.1. The FileFilter Class
        1. 12.2.1.1. Constructor
        2. 12.2.1.2. Filter methods
      2. 12.2.2. The FileView Class
        1. 12.2.2.1. Constructor
        2. 12.2.2.2. Methods
      3. 12.2.3. The FileSystemView Class
        1. 12.2.3.1. Class instantiation method
        2. 12.2.3.2. File and folder methods
    3. 12.3. The Color Chooser
      1. 12.3.1. The ColorSelectionModel Interface
        1. 12.3.1.1. Property
        2. 12.3.1.2. Events
      2. 12.3.2. The DefaultColorSelectionModel Class
        1. 12.3.2.1. Properties
        2. 12.3.2.2. Events
        3. 12.3.2.3. Constructors
    4. 12.4. The JColorChooser Class
      1. 12.4.1. Properties
      2. 12.4.2. Events (Inherited from JComponent)
      3. 12.4.3. Constants
      4. 12.4.4. Constructors
      5. 12.4.5. Dialog Methods
      6. 12.4.6. Chooser Methods
      7. 12.4.7. The AbstractColorChooserPanel Class
        1. 12.4.7.1. Properties
        2. 12.4.7.2. Protected helper method
        3. 12.4.7.3. Chooser panel methods
      8. 12.4.8. The ColorChooserComponentFactory Class
        1. 12.4.8.1. Methods
    5. 12.5. Developing a Custom Chooser Panel
    6. 12.6. Developing a Custom Preview Panel
    7. 12.7. Developing a Custom Dialog
  16. 13. Borders
    1. 13.1. Introducing Borders
      1. 13.1.1. The Border Interface
        1. 13.1.1.1. Methods
    2. 13.2. Painting Borders Correctly
      1. 13.2.1. The AbstractBorder Class
        1. 13.2.1.1. Property
        2. 13.2.1.2. Constructor
        3. 13.2.1.3. Methods
    3. 13.3. Swing Borders
      1. 13.3.1. The BevelBorder and SoftBevelBorder Classes
        1. 13.3.1.1. Properties
        2. 13.3.1.2. Constants
        3. 13.3.1.3. Default colors
        4. 13.3.1.4. Constructors
        5. 13.3.1.5. Methods
        6. 13.3.1.6. Changing borders on the fly
      2. 13.3.2. The Empty Border Class
        1. 13.3.2.1. Properties
        2. 13.3.2.2. Constructors
        3. 13.3.2.3. Method
      3. 13.3.3. The EtchedBorder Class
        1. 13.3.3.1. Properties
        2. 13.3.3.2. Constants
        3. 13.3.3.3. Constructors
        4. 13.3.3.4. Miscellaneous
      4. 13.3.4. The LineBorder Class
        1. 13.3.4.1. Properties
        2. 13.3.4.2. Constructors
        3. 13.3.4.3. Methods
        4. 13.3.4.4. Miscellaneous
      5. 13.3.5. The MatteBorder Class
        1. 13.3.5.1. Properties
        2. 13.3.5.2. Constructors
        3. 13.3.5.3. Methods
        4. 13.3.5.4. Two kinds of matte borders
      6. 13.3.6. The TitledBorder Class
        1. 13.3.6.1. Properties
        2. 13.3.6.2. Constructors
        3. 13.3.6.3. Miscellaneous
        4. 13.3.6.4. Using a titled border
      7. 13.3.7. The CompoundBorder Class
        1. 13.3.7.1. Properties
        2. 13.3.7.2. Constructors
        3. 13.3.7.3. Miscellaneous
      8. 13.3.8. The BorderFactory Class
        1. 13.3.8.1. Methods
    4. 13.4. Creating Your Own Border
  17. 14. Menus and Toolbars
    1. 14.1. Introducing Swing Menus
      1. 14.1.1. Menu Hierarchy
      2. 14.1.2. Getting Your Feet Wet
    2. 14.2. Menu Bar Selection Models
      1. 14.2.1. The SingleSelectionModel Interface
        1. 14.2.1.1. Properties
        2. 14.2.1.2. Events
        3. 14.2.1.3. Method
      2. 14.2.2. The DefaultSingleSelectionModel Class
        1. 14.2.2.1. Properties
        2. 14.2.2.2. Events and methods
    3. 14.3. The JMenuBar Class
      1. 14.3.1. Menu Bar Placement
      2. 14.3.2. Properties
        1. 14.3.2.1. Constructor
        2. 14.3.2.2. Menu
        3. 14.3.2.3. Miscellaneous
    4. 14.4. The JMenuItem Class
      1. 14.4.1. Menu Item Shortcuts
      2. 14.4.2. Images
      3. 14.4.3. Event Handling
      4. 14.4.4. Properties
      5. 14.4.5. Constructors
      6. 14.4.6. Events
      7. 14.4.7. Method
      8. 14.4.8. Menu Element Interface
      9. 14.4.9. The MenuDragMouseEvent Class
        1. 14.4.9.1. Properties
        2. 14.4.9.2. Constructor
      10. 14.4.10. The MenuDragMouseListener Interface
        1. 14.4.10.1. Methods
      11. 14.4.11. The MenuKeyEvent Class
        1. 14.4.11.1. Constructor
      12. 14.4.12. The MenuKeyListener Interface
        1. 14.4.12.1. Methods
    5. 14.5. The JPopupMenu Class
      1. 14.5.1. Displaying the Pop-up Menu
      2. 14.5.2. Properties
      3. 14.5.3. Events
      4. 14.5.4. Constructors
      5. 14.5.5. Menu Items
      6. 14.5.6. Display
      7. 14.5.7. Miscellaneous
      8. 14.5.8. Menu Element Interface
      9. 14.5.9. Using Pop-up Menus
      10. 14.5.10. The PopupMenuEvent Class
        1. 14.5.10.1. Constructor
      11. 14.5.11. The PopupMenuListener Interface
        1. 14.5.11.1. Methods
    6. 14.6. The JMenu Class
      1. 14.6.1. Properties
      2. 14.6.2. Constructor
      3. 14.6.3. Menu Items
      4. 14.6.4. Miscellaneous
      5. 14.6.5. Event
      6. 14.6.6. MenuElement Interface
      7. 14.6.7. Working with Menus
      8. 14.6.8. The MenuEvent Class
        1. 14.6.8.1. Constructor
      9. 14.6.9. The MenuListener Interface
        1. 14.6.9.1. Methods
    7. 14.7. Selectable Menu Items
      1. 14.7.1. The JCheckBoxMenuItem Class
        1. 14.7.1.1. Properties
        2. 14.7.1.2. Constructors
        3. 14.7.1.3. Miscellaneous
      2. 14.7.2. Using Checkbox Menu Items
      3. 14.7.3. The JRadioButtonMenuItem Class
        1. 14.7.3.1. Properties
        2. 14.7.3.2. Constructor
        3. 14.7.3.3. Miscellaneous
      4. 14.7.4. Enforcing Mutual Exclusion
      5. 14.7.5. The JSeparator Class
        1. 14.7.5.1. Properties
        2. 14.7.5.2. Constructor
        3. 14.7.5.3. Miscellaneous
      6. 14.7.6. Using a Separator Outside of a Menu
      7. 14.7.7. The MenuElement Interface
        1. 14.7.7.1. Methods
      8. 14.7.8. Making Arbitrary Components into Menu Elements
    8. 14.8. Toolbars
      1. 14.8.1. The JToolBar Class
        1. 14.8.1.1. Floating toolbars
        2. 14.8.1.2. Properties
        3. 14.8.1.3. Event
        4. 14.8.1.4. Constructor
        5. 14.8.1.5. Adding actions
        6. 14.8.1.6. Miscellaneous
      2. 14.8.2. Creating a Toolbar
  18. 15. Tables
    1. 15.1. The JTable Class
      1. 15.1.1. Table Columns
      2. 15.1.2. Properties
        1. 15.1.2.1. Examples
      3. 15.1.3. Events
      4. 15.1.4. Constants
      5. 15.1.5. Constructors
      6. 15.1.6. Other Interesting Methods
      7. 15.1.7. The TableColumn Class
        1. 15.1.7.1. Properties
        2. 15.1.7.2. Constants
        3. 15.1.7.3. Event
        4. 15.1.7.4. Constructors
        5. 15.1.7.5. Another useful method
      8. 15.1.8. The TableColumnModel Interface
        1. 15.1.8.1. Properties
        2. 15.1.8.2. Event
        3. 15.1.8.3. Column methods
      9. 15.1.9. The DefaultTableColumnModel Class
        1. 15.1.9.1. Properties
        2. 15.1.9.2. Events
        3. 15.1.9.3. Constructor
        4. 15.1.9.4. Other useful methods
      10. 15.1.10. The TableColumnModelEvent Class
        1. 15.1.10.1. Event methods
      11. 15.1.11. The TableColumnModelListener Interface
    2. 15.2. Implementing a Column Model
    3. 15.3. Table Data
      1. 15.3.1. The TableModel Interface
        1. 15.3.1.1. Properties
        2. 15.3.1.2. Events
        3. 15.3.1.3. Cell methods
      2. 15.3.2. The AbstractTableModel Class
        1. 15.3.2.1. Events
        2. 15.3.2.2. Another useful method
      3. 15.3.3. The DefaultTableModel Class
        1. 15.3.3.1. Properties
        2. 15.3.3.2. Events
        3. 15.3.3.3. Constructors
        4. 15.3.3.4. Other useful methods
      4. 15.3.4. The TableModelEvent Class
        1. 15.3.4.1. Properties
        2. 15.3.4.2. Constants
      5. 15.3.5. The TableModelListener Interface
      6. 15.3.6. Dynamic Table Data
      7. 15.3.7. Database Data
      8. 15.3.8. Yet More Useful Methods
      9. 15.3.9. The JTableHeader Class
        1. 15.3.9.1. Properties
    4. 15.4. Selecting Table Entries
    5. 15.5. Rendering Cells
      1. 15.5.1. The TableCellRenderer Interface
      2. 15.5.2. The DefaultTableCellRenderer Class
        1. 15.5.2.1. Properties
      3. 15.5.3. The CellRendererPane Class
    6. 15.6. Editing Cells
      1. 15.6.1. The CellEditor Interface
        1. 15.6.1.1. Events
        2. 15.6.1.2. Methods
      2. 15.6.2. The TableCellEditor Interface
      3. 15.6.3. The CellEditorListener Interface
      4. 15.6.4. The DefaultCellEditor Class
        1. 15.6.4.1. Properties
        2. 15.6.4.2. Events
        3. 15.6.4.3. Constructors
        4. 15.6.4.4. Tree and table editor methods
    7. 15.7. Next Steps
  19. 16. Advanced Table Examples
    1. 16.1. A Table with Row Headers
    2. 16.2. Large Tables with Paging
    3. 16.3. A Table with Custom Editing and Rendering
      1. 16.3.1. A Custom Renderer
      2. 16.3.2. A Custom Editor
    4. 16.4. Charting Data with a TableModel
  20. 17. Trees
    1. 17.1. A Simple Tree
      1. 17.1.1. Tree Terminology
    2. 17.2. Tree Models
      1. 17.2.1. The TreeModel Interface
        1. 17.2.1.1. Property
        2. 17.2.1.2. Events
        3. 17.2.1.3. Miscellaneous methods
      2. 17.2.2. The DefaultTreeModel Class
        1. 17.2.2.1. Properties
        2. 17.2.2.2. Events
        3. 17.2.2.3. Constructors
        4. 17.2.2.4. Miscellaneous methods
      3. 17.2.3. Working with Tree Models
    3. 17.3. The JTree Class
      1. 17.3.1. Properties
      2. 17.3.2. Events
      3. 17.3.3. Constants
      4. 17.3.4. Constructors
      5. 17.3.5. Selection Methods
      6. 17.3.6. Expansion Methods
      7. 17.3.7. Path and Row Methods
      8. 17.3.8. Editing Methods
      9. 17.3.9. JTree Inner Classes
    4. 17.4. Tree Nodes and Paths
      1. 17.4.1. The TreeNode Interface
        1. 17.4.1.1. Properties
        2. 17.4.1.2. Child access methods
      2. 17.4.2. The MutableTreeNode Interface
        1. 17.4.2.1. Properties
        2. 17.4.2.2. Mutation methods
      3. 17.4.3. The DefaultMutableTreeNode Class
        1. 17.4.3.1. Constant
        2. 17.4.3.2. Constructors
        3. 17.4.3.3. Structure methods
        4. 17.4.3.4. Enumeration methods
      4. 17.4.4. The TreePath Class
        1. 17.4.4.1. Properties
        2. 17.4.4.2. Constructors
        3. 17.4.4.3. Miscellaneous methods
    5. 17.5. Tree Selections
      1. 17.5.1. The RowMapper Interface
      2. 17.5.2. The TreeSelectionModel Interface
        1. 17.5.2.1. Properties
        2. 17.5.2.2. Constants
        3. 17.5.2.3. Events
        4. 17.5.2.4. Selection methods
      3. 17.5.3. The DefaultTreeSelectionModel Class
        1. 17.5.3.1. Properties
        2. 17.5.3.2. Events
        3. 17.5.3.3. Constant
        4. 17.5.3.4. Constructor
    6. 17.6. Tree Events
      1. 17.6.1. The TreeModelEvent Class
        1. 17.6.1.1. Properties
        2. 17.6.1.2. Constructors
      2. 17.6.2. The TreeModelListener Interface
      3. 17.6.3. The TreeSelectionEvent Class
        1. 17.6.3.1. Properties
        2. 17.6.3.2. Constructors
        3. 17.6.3.3. Methods
      4. 17.6.4. The TreeSelectionListener Interface
      5. 17.6.5. The TreeExpansionEvent Class
        1. 17.6.5.1. Property
        2. 17.6.5.2. Constructor
      6. 17.6.6. The TreeExpansionListener Interface
      7. 17.6.7. Pending Expansion Events
        1. 17.6.7.1. The TreeWillExpandListener interface
        2. 17.6.7.2. The ExpandVetoException class
    7. 17.7. Rendering and Editing
      1. 17.7.1. Rendering Nodes
        1. 17.7.1.1. But I just want to change the icons!
      2. 17.7.2. The DefaultTreeCellRenderer Class
        1. 17.7.2.1. Properties
        2. 17.7.2.2. Constructor
      3. 17.7.3. Custom Renderers
      4. 17.7.4. The TreeCellRenderer Interface
      5. 17.7.5. Editing Nodes
      6. 17.7.6. The TreeCellEditor Interface
      7. 17.7.7. The DefaultTreeCellEditor Class
        1. 17.7.7.1. Properties
        2. 17.7.7.2. Events
        3. 17.7.7.3. Constructors
        4. 17.7.7.4. CellEditor and TreeCellEditor methods
      8. 17.7.8. Look-and-Feel Helper Classes
    8. 17.8. What Next?
  21. 18. Undo
    1. 18.1. The Swing Undo Facility
      1. 18.1.1. The UndoableEdit Interface
        1. 18.1.1.1. Properties
        2. 18.1.1.2. Edit-merging methods
        3. 18.1.1.3. Other methods
      2. 18.1.2. The AbstractUndoableEdit Class
        1. 18.1.2.1. Properties
        2. 18.1.2.2. Constants
        3. 18.1.2.3. Constructor
        4. 18.1.2.4. UndoableEdit methods
        5. 18.1.2.5. Creating a toggle edit
      3. 18.1.3. The CompoundEdit Class
        1. 18.1.3.1. Properties
        2. 18.1.3.2. Protected field
        3. 18.1.3.3. Constructor
        4. 18.1.3.4. UndoableEdit methods
        5. 18.1.3.5. Other methods
      4. 18.1.4. Using Compound Edits
      5. 18.1.5. The UndoableEditEvent Class
        1. 18.1.5.1. Property
        2. 18.1.5.2. Constructor
      6. 18.1.6. The UndoableEditListener Interface
    2. 18.2. The UndoManager Class
      1. 18.2.1. A Codeless Example
      2. 18.2.2. Transformer?
      3. 18.2.3. Properties
      4. 18.2.4. Constructor
      5. 18.2.5. UndoableEditListener Method
      6. 18.2.6. UndoableEdit Methods
      7. 18.2.7. Public Methods
      8. 18.2.8. Protected Methods
      9. 18.2.9. Using an Undo Manager
      10. 18.2.10. Understanding the UndoManager
      11. 18.2.11. The StateEditable Interface
        1. 18.2.11.1. Methods
      12. 18.2.12. The StateEdit Class
        1. 18.2.12.1. State optimization
        2. 18.2.12.2. Property
        3. 18.2.12.3. Protected fields
        4. 18.2.12.4. Constructors
        5. 18.2.12.5. UndoableEdit methods
        6. 18.2.12.6. New public method
        7. 18.2.12.7. Protected methods
        8. 18.2.12.8. StateEdit example
      13. 18.2.13. The UndoableEditSupport Class
        1. 18.2.13.1. Properties
        2. 18.2.13.2. Protected fields
        3. 18.2.13.3. Constructors
        4. 18.2.13.4. UndoableEditEvent/listener support methods
        5. 18.2.13.5. Nested edit support
      14. 18.2.14. Using Undoable Edit Support
      15. 18.2.15. The CannotRedoException Class
      16. 18.2.16. The CannotUndoException Class
    3. 18.3. Extending UndoManager
  22. 19. Text 101
    1. 19.1. The Swing Text Components
    2. 19.2. The JTextComponent Class
      1. 19.2.1. Properties
      2. 19.2.2. Events
      3. 19.2.3. Constants
      4. 19.2.4. Constructor
      5. 19.2.5. Clipboard Methods
      6. 19.2.6. Selection Methods
      7. 19.2.7. View Methods
      8. 19.2.8. Working with Keymaps
      9. 19.2.9. Other Methods
    3. 19.3. The JTextField Class
      1. 19.3.1. Properties
      2. 19.3.2. Events
      3. 19.3.3. Constant
      4. 19.3.4. Constructors
      5. 19.3.5. Methods
    4. 19.4. A Simple Form
      1. 19.4.1. Understanding JTextField Sizing
        1. 19.4.1.1. Restricting input
    5. 19.5. The JPasswordField Class
      1. 19.5.1. Properties
      2. 19.5.2. Constructors
      3. 19.5.3. Data Protection Methods
      4. 19.5.4. Miscellaneous Methods
    6. 19.6. The JTextArea Class
      1. 19.6.1. Properties
      2. 19.6.2. Events
      3. 19.6.3. Constructors
      4. 19.6.4. Text Manipulation Methods
      5. 19.6.5. Line Transformation Methods
      6. 19.6.6. Understanding JTextArea Layout
    7. 19.7. How It All Works
  23. 20. Formatted Text Fields
    1. 20.1. The JFormattedTextField Class
      1. 20.1.1. Properties
      2. 20.1.2. Events
      3. 20.1.3. Constants
      4. 20.1.4. Constructors
      5. 20.1.5. Public Method
    2. 20.2. Handling Numerics
      1. 20.2.1. The JFormattedTextField.AbstractFormatter Class
        1. 20.2.1.1. Public methods
        2. 20.2.1.2. Protected methods
    3. 20.3. The DefaultFormatter Class
      1. 20.3.1. Properties
      2. 20.3.2. Constructor
      3. 20.3.3. Public Methods
      4. 20.3.4. Example
    4. 20.4. The MaskFormatter Class
      1. 20.4.1. Properties
      2. 20.4.2. Constructors
      3. 20.4.3. Public Methods
    5. 20.5. The InternationalFormatter Class
      1. 20.5.1. Properties
      2. 20.5.2. Constructors
      3. 20.5.3. Public Methods
    6. 20.6. The DateFormatter Class
      1. 20.6.1. Properties
      2. 20.6.2. Constructors
    7. 20.7. The NumberFormatter Class
      1. 20.7.1. Properties
      2. 20.7.2. Constructors
      3. 20.7.3. Public Method
      4. 20.7.4. The JFormattedTextField.AbstractFormatterFactory Class
        1. 20.7.4.1. Public method
    8. 20.8. The DefaultFormatterFactory Class
      1. 20.8.1. Properties
      2. 20.8.2. Constructors
      3. 20.8.3. Public Method
      4. 20.8.4. Example
    9. 20.9. Formatting with Regular Expressions
    10. 20.10. The InputVerifier Class
      1. 20.10.1. Public Methods
  24. 21. Carets, Highlighters, and Keymaps
    1. 21.1. Carets
      1. 21.1.1. The Caret Interface
        1. 21.1.1.1. Properties
        2. 21.1.1.2. Events
        3. 21.1.1.3. Methods
      2. 21.1.2. The DefaultCaret Class
        1. 21.1.2.1. Properties
        2. 21.1.2.2. Events
        3. 21.1.2.3. Constructor
        4. 21.1.2.4. Caret methods
        5. 21.1.2.5. FocusListener methods
        6. 21.1.2.6. Mouse methods
        7. 21.1.2.7. Protected methods
      3. 21.1.3. Custom Carets
      4. 21.1.4. The CaretListener Interface
        1. 21.1.4.1. Method
      5. 21.1.5. The CaretEvent Class
        1. 21.1.5.1. Properties
        2. 21.1.5.2. Constructor
    2. 21.2. Highlighters
      1. 21.2.1. The Highlighter.HighlightPainter Interface
        1. 21.2.1.1. Method
      2. 21.2.2. A Custom HighlightPainter
      3. 21.2.3. The Highlighter.Highlight Interface
        1. 21.2.3.1. Properties
      4. 21.2.4. The Highlighter Interface
        1. 21.2.4.1. Property
        2. 21.2.4.2. Methods
      5. 21.2.5. Adding Multiple Highlights
      6. 21.2.6. The LayeredHighlighter Class
        1. 21.2.6.1. Method
      7. 21.2.7. The DefaultHighlighter Class
        1. 21.2.7.1. Properties
        2. 21.2.7.2. Static field
        3. 21.2.7.3. Constructor
        4. 21.2.7.4. Methods
      8. 21.2.8. The DefaultHighlighter.DefaultHighlightPainter Class
        1. 21.2.8.1. Property
        2. 21.2.8.2. Constructor
        3. 21.2.8.3. Methods
    3. 21.3. Keymaps
      1. 21.3.1. The Keymap Interface
        1. 21.3.1.1. Properties
        2. 21.3.1.2. Methods
      2. 21.3.2. Keymap Implementation
      3. 21.3.3. Adding Keyboard Actions
  25. 22. Styled Text Panes
    1. 22.1. The JTextPane Class
      1. 22.1.1. Properties
      2. 22.1.2. Constructors
      3. 22.1.3. Attribute and Style Methods
      4. 22.1.4. Insertion/Replacement Methods
      5. 22.1.5. Named Style Methods
    2. 22.2. AttributeSets and Styles
      1. 22.2.1. The AttributeSet Interface
        1. 22.2.1.1. Properties
        2. 22.2.1.2. Constants
        3. 22.2.1.3. Methods
        4. 22.2.1.4. Inner interfaces
      2. 22.2.2. The MutableAttributeSet Interface
        1. 22.2.2.1. Property
        2. 22.2.2.2. Methods
      3. 22.2.3. The Style Interface
        1. 22.2.3.1. Property
        2. 22.2.3.2. Constants
        3. 22.2.3.3. Events
      4. 22.2.4. The SimpleAttributeSet Class
        1. 22.2.4.1. Properties
        2. 22.2.4.2. Constant
        3. 22.2.4.3. Constructors
        4. 22.2.4.4. Add/remove methods
        5. 22.2.4.5. Query methods
      5. 22.2.5. The StyleConstants Class
        1. 22.2.5.1. Attribute key constants and utility methods
          1. 22.2.5.1.1. Character attribute keys
          2. 22.2.5.1.2. Paragraph attribute keys
          3. 22.2.5.1.3. Other attribute keys
        2. 22.2.5.2. Attribute value constants
        3. 22.2.5.3. StyleConstants inner classes
      6. 22.2.6. The StyleContext Class
        1. 22.2.6.1. Properties
        2. 22.2.6.2. Events
        3. 22.2.6.3. Constant
        4. 22.2.6.4. Constructor
        5. 22.2.6.5. Static default accessor method
        6. 22.2.6.6. AttributeContext methods
        7. 22.2.6.7. Font and color accessor methods
        8. 22.2.6.8. Style management methods
        9. 22.2.6.9. Serialization methods
      7. 22.2.7. A Stylized Editor
      8. 22.2.8. The TabStop Class
        1. 22.2.8.1. Properties
        2. 22.2.8.2. Alignment constants
        3. 22.2.8.3. Leader constants
        4. 22.2.8.4. Constructors
      9. 22.2.9. The TabSet Class
        1. 22.2.9.1. Properties
        2. 22.2.9.2. Constructor
        3. 22.2.9.3. Methods
        4. 22.2.9.4. Example
    3. 22.3. The Document Model
      1. 22.3.1. The Element Interface
        1. 22.3.1.1. Properties
        2. 22.3.1.2. Element lookup method
      2. 22.3.2. The Document Interface
        1. 22.3.2.1. Properties
        2. 22.3.2.2. Events
        3. 22.3.2.3. Constants
        4. 22.3.2.4. Text manipulation methods
        5. 22.3.2.5. Other methods
      3. 22.3.3. The AbstractDocument Class
        1. 22.3.3.1. Properties
        2. 22.3.3.2. Events
        3. 22.3.3.3. Constants
        4. 22.3.3.4. Constructors
        5. 22.3.3.5. Locking methods
        6. 22.3.3.6. Text manipulation methods
        7. 22.3.3.7. Other public methods
      4. 22.3.4. The PlainDocument Class
        1. 22.3.4.1. Properties
        2. 22.3.4.2. Constants
        3. 22.3.4.3. Constructors
        4. 22.3.4.4. Public methods
        5. 22.3.4.5. Restriction example
      5. 22.3.5. The StyledDocument Interface
        1. 22.3.5.1. Properties
        2. 22.3.5.2. Style application methods
        3. 22.3.5.3. Query methods
        4. 22.3.5.4. StyleContext delegation methods
      6. 22.3.6. The DefaultStyledDocument Class
        1. 22.3.6.1. Properties
        2. 22.3.6.2. Events
        3. 22.3.6.3. Constant
        4. 22.3.6.4. Constructors
        5. 22.3.6.5. Content style methods
        6. 22.3.6.6. StyleContext delegation methods
        7. 22.3.6.7. StyledDocument example
    4. 22.4. Document Events
      1. 22.4.1. The DocumentListener Interface
        1. 22.4.1.1. Methods
      2. 22.4.2. The DocumentEvent Interface
        1. 22.4.2.1. Properties
        2. 22.4.2.2. Element tree details
      3. 22.4.3. The DocumentEvent.EventType Class
      4. 22.4.4. The DocumentEvent.ElementChange Interface
        1. 22.4.4.1. Properties
      5. 22.4.5. The ElementIterator Class
        1. 22.4.5.1. Constructors
        2. 22.4.5.2. Methods
      6. 22.4.6. The Segment Class
        1. 22.4.6.1. Properties
        2. 22.4.6.2. Constant
        3. 22.4.6.3. Fields
        4. 22.4.6.4. Constructors
        5. 22.4.6.5. Methods
      7. 22.4.7. The AbstractDocument.Content Interface
        1. 22.4.7.1. Methods
      8. 22.4.8. The StringContent Class
        1. 22.4.8.1. Constructors
      9. 22.4.9. The GapContent Class
        1. 22.4.9.1. Constructors
        2. 22.4.9.2. AbstractDocument.Content methods
      10. 22.4.10. Undo Event Example
      11. 22.4.11. The BadLocationException Class
        1. 22.4.11.1. Constructor
        2. 22.4.11.2. Method
      12. 22.4.12. The Position Interface
        1. 22.4.12.1. Property
      13. 22.4.13. The Position.Bias Class
        1. 22.4.13.1. Constants
    5. 22.5. Views
      1. 22.5.1. The ViewFactory Interface
        1. 22.5.1.1. Method
      2. 22.5.2. The View Class
        1. 22.5.2.1. Float coordinates
        2. 22.5.2.2. Shape versus Rectangle
        3. 22.5.2.3. Span and allocation
        4. 22.5.2.4. Axis
        5. 22.5.2.5. Bias
        6. 22.5.2.6. Properties
        7. 22.5.2.7. Constructor
        8. 22.5.2.8. Constants
        9. 22.5.2.9. Abstract methods
        10. 22.5.2.10. Translation methods
        11. 22.5.2.11. Break methods
        12. 22.5.2.12. Tree management methods
        13. 22.5.2.13. Layout methods
        14. 22.5.2.14. Update methods
      3. 22.5.3. The View Classes
      4. 22.5.4. The TabExpander Interface
        1. 22.5.4.1. Method
      5. 22.5.5. The TabableView Interface
        1. 22.5.5.1. Methods
      6. 22.5.6. The Utilities Class
        1. 22.5.6.1. Public static methods
    6. 22.6. The DocumentFilter Class
      1. 22.6.1. Constructor
        1. 22.6.1.1. Methods
        2. 22.6.1.2. DocumentFilter.FilterBypass methods
    7. 22.7. The NavigationFilter Class
      1. 22.7.1. Constructor
        1. 22.7.1.1. Methods
        2. 22.7.1.2. NavigationFilter.FilterBypass methods
  26. 23. Editor Panes and Editor Kits
    1. 23.1. The JEditorPane Class
      1. 23.1.1. Properties
      2. 23.1.2. Events
      3. 23.1.3. Constructors
      4. 23.1.4. EditorKit Methods
      5. 23.1.5. Miscellaneous Methods
    2. 23.2. Overview of the Editor Kits
      1. 23.2.1. The EditorKit Class
        1. 23.2.1.1. Properties
        2. 23.2.1.2. Abstract methods
        3. 23.2.1.3. Other methods
      2. 23.2.2. The TextAction Class
        1. 23.2.2.1. Constructor
        2. 23.2.2.2. Static method
        3. 23.2.2.3. Protected methods
      3. 23.2.3. The DefaultEditorKit Class
        1. 23.2.3.1. Properties
        2. 23.2.3.2. Constants
        3. 23.2.3.3. Using actions
        4. 23.2.3.4. Constructor
        5. 23.2.3.5. Methods
      4. 23.2.4. Useful Actions
      5. 23.2.5. A Simple Text Editor
      6. 23.2.6. The StyledEditorKit Class
        1. 23.2.6.1. Properties
        2. 23.2.6.2. Constructor
        3. 23.2.6.3. EditorKit methods
      7. 23.2.7. The StyledEditorKit.StyledTextAction Class
        1. 23.2.7.1. Constructor
        2. 23.2.7.2. Protected methods
        3. 23.2.7.3. The StyledEditorKit.FontFamilyAction class
        4. 23.2.7.4. The StyledEditorKit.FontSizeAction class
        5. 23.2.7.5. The StyledEditorKit.ForegroundAction class
        6. 23.2.7.6. The StyledEditorKit.AlignmentAction class
        7. 23.2.7.7. The StyledEditorKit.BoldAction class
        8. 23.2.7.8. The StyledEditorKit.ItalicAction class
        9. 23.2.7.9. The StyledEditorKit.UnderlineAction class
      8. 23.2.8. A Better Editor
        1. 23.2.8.1. Saving styled documents
    3. 23.3. HTML and JEditorPane
      1. 23.3.1. A Quick Browser Example
    4. 23.4. Hyperlink Events
      1. 23.4.1. The HyperlinkListener Interface
      2. 23.4.2. The HyperlinkEvent Class
        1. 23.4.2.1. Properties
        2. 23.4.2.2. Constructors
        3. 23.4.2.3. Inner classes
      3. 23.4.3. The HTMLFrameHyperlinkEvent Class
    5. 23.5. The HTMLEditorKit Class
      1. 23.5.1. Inner Classes
      2. 23.5.2. Properties
      3. 23.5.3. Constructor
      4. 23.5.4. Editor Kit Methods
      5. 23.5.5. HTML Document Methods
    6. 23.6. Extending HTMLEditorKit
      1. 23.6.1. The HTMLDocument Class
        1. 23.6.1.1. Properties
        2. 23.6.1.2. Constructors
        3. 23.6.1.3. Public content methods
      2. 23.6.2. The HTML Class
        1. 23.6.2.1. Inner classes
      3. 23.6.3. The StyleSheet Class
        1. 23.6.3.1. Properties
    7. 23.7. Editing HTML
      1. 23.7.1. Hyperlink Actions
      2. 23.7.2. Inserting Images
      3. 23.7.3. Saving as HTML
    8. 23.8. Writing HTML
      1. 23.8.1. The AbstractWriter Class
        1. 23.8.1.1. Properties
        2. 23.8.1.2. Constant
        3. 23.8.1.3. Constructors
        4. 23.8.1.4. Output-generating methods
        5. 23.8.1.5. Formatting methods
      2. 23.8.2. The HTMLWriter Class
        1. 23.8.2.1. Constructors
        2. 23.8.2.2. Writing method
      3. 23.8.3. MinimalHTMLWriter
        1. 23.8.3.1. Constructors
        2. 23.8.3.2. Public writing method
    9. 23.9. Reading HTML
      1. 23.9.1. Document Parsers
    10. 23.10. A Custom EditorKit
      1. 23.10.1. Create the EditorKit Class
      2. 23.10.2. Define the Document Type
      3. 23.10.3. Define New Actions
      4. 23.10.4. Create Custom View Classes
      5. 23.10.5. Create a ViewFactory Interface and View Classes
      6. 23.10.6. Create a “Reader” and a “Writer”
      7. 23.10.7. Tell JEditorPane About Your New Kit
  27. 24. Drag and Drop
    1. 24.1. What Is Drag and Drop?
      1. 24.1.1. DnD and SDK 1.4
      2. 24.1.2. Programming with DnD
    2. 24.2. The Drop API
      1. 24.2.1. The DropTarget Class
        1. 24.2.1.1. Properties
        2. 24.2.1.2. Events
        3. 24.2.1.3. Constructors
      2. 24.2.2. The DnDConstants Class
      3. 24.2.3. The DropTargetContext Class
        1. 24.2.3.1. Properties
      4. 24.2.4. The DropTargetListener Interface
        1. 24.2.4.1. Methods
      5. 24.2.5. The DropTargetAdapter Class
      6. 24.2.6. The DropTargetEvent Class
      7. 24.2.7. The DropTargetDragEvent Class
        1. 24.2.7.1. Properties
        2. 24.2.7.2. Drag methods
        3. 24.2.7.3. Transfer data method
      8. 24.2.8. The DropTargetDropEvent Class
        1. 24.2.8.1. Properties
        2. 24.2.8.2. Drop methods
        3. 24.2.8.3. Transfer data method
      9. 24.2.9. Drop Example
      10. 24.2.10. Transferable Contents
      11. 24.2.11. The TransferHandler Class
        1. 24.2.11.1. Constants
        2. 24.2.11.2. Properties
        3. 24.2.11.3. Constructors
        4. 24.2.11.4. Methods
    3. 24.3. The Drag Gesture API
      1. 24.3.1. The DragGestureRecognizer Class
        1. 24.3.1.1. Properties
        2. 24.3.1.2. Events
        3. 24.3.1.3. Fields
        4. 24.3.1.4. Constructors
        5. 24.3.1.5. Trigger event list methods
      2. 24.3.2. The MouseDragGestureRecognizer Class
        1. 24.3.2.1. Constructors
        2. 24.3.2.2. Mouse methods
        3. 24.3.2.3. Listener methods
      3. 24.3.3. The Drag Gesture Events and Listeners
        1. 24.3.3.1. Properties
        2. 24.3.3.2. Event list methods
        3. 24.3.3.3. Drag initiation methods
      4. 24.3.4. A Simple Gesture
    4. 24.4. The Drag API
      1. 24.4.1. The DragSource Class
        1. 24.4.1.1. Properties
        2. 24.4.1.2. Constants
        3. 24.4.1.3. Events
        4. 24.4.1.4. Constructor
        5. 24.4.1.5. Helper creation methods
        6. 24.4.1.6. Start methods
      2. 24.4.2. The DragSourceContext Class
        1. 24.4.2.1. Properties
        2. 24.4.2.2. Events
        3. 24.4.2.3. Protected constants
        4. 24.4.2.4. Constructors
        5. 24.4.2.5. Event methods
        6. 24.4.2.6. Miscellaneous methods
      3. 24.4.3. The DragSourceListener Interface
        1. 24.4.3.1. Event methods
      4. 24.4.4. The DragSourceMotionListener Interface
        1. 24.4.4.1. Event method
      5. 24.4.5. The DragSourceAdapter Class
      6. 24.4.6. Drag Source Events
        1. 24.4.6.1. Constructors
      7. 24.4.7. The DragSourceDragEvent Class
        1. 24.4.7.1. Properties
      8. 24.4.8. The DragSourceDropEvent Class
        1. 24.4.8.1. Properties
      9. 24.4.9. Completing the Gesture
    5. 24.5. Rearranging Trees
      1. 24.5.1. A TransferHandler Example
      2. 24.5.2. A Rearranging Example
    6. 24.6. Finishing Touches
      1. 24.6.1. Dynamic Cursors
      2. 24.6.2. Changing the Drop Action
      3. 24.6.3. Autoscrolling
      4. 24.6.4. The Autoscroll Interface
        1. 24.6.4.1. Methods
      5. 24.6.5. The DropTarget.DropTargetAutoScroller Class
        1. 24.6.5.1. Constructor
        2. 24.6.5.2. Methods
  28. 25. Programming with Accessibility
    1. 25.1. How Accessibility Works
      1. 25.1.1. Evolving Accessibility Support
        1. 25.1.1.1. Version 1.1 accessibility
        2. 25.1.1.2. Version 1.2 accessibility
        3. 25.1.1.3. Version 1.3 accessibility
        4. 25.1.1.4. Version 1.4 accessibility
      2. 25.1.2. The Accessibility Contract
      3. 25.1.3. How Do I Get It?
        1. 25.1.3.1. Swing
        2. 25.1.3.2. AWT
    2. 25.2. The Accessibility Package
      1. 25.2.1. The Path to Determining Accessibility
      2. 25.2.2. The Accessible Interface
        1. 25.2.2.1. Method
      3. 25.2.3. The AccessibleContext Class
        1. 25.2.3.1. Properties
        2. 25.2.3.2. Accessible names and descriptions
        3. 25.2.3.3. Events
        4. 25.2.3.4. Constants
    3. 25.3. Other Accessible Objects
      1. 25.3.1. The AccessibleState Class
        1. 25.3.1.1. Constructor
      2. 25.3.2. The AccessibleStateSet Class
        1. 25.3.2.1. Constructors
        2. 25.3.2.2. Methods
      3. 25.3.3. The AccessibleRole Class
        1. 25.3.3.1. Constructor
    4. 25.4. Types of Accessibility
      1. 25.4.1. The AccessibleAction Interface
        1. 25.4.1.1. Properties
        2. 25.4.1.2. Method
      2. 25.4.2. The AccessibleComponent Interface
        1. 25.4.2.1. Properties
        2. 25.4.2.2. Events
        3. 25.4.2.3. Methods
      3. 25.4.3. The AccessibleSelection Interface
        1. 25.4.3.1. Properties
        2. 25.4.3.2. Methods
      4. 25.4.4. The AccessibleText Interface
        1. 25.4.4.1. Properties
        2. 25.4.4.2. Constants
        3. 25.4.4.3. Methods
      5. 25.4.5. The AccessibleHypertext Interface
        1. 25.4.5.1. Properties
      6. 25.4.6. The AccessibleHyperlink Class
        1. 25.4.6.1. Properties
        2. 25.4.6.2. Method
      7. 25.4.7. The AccessibleValue Interface
        1. 25.4.7.1. Methods
    5. 25.5. Classes Added in SDK 1.3 and 1.4
      1. 25.5.1. The AccessibleIcon Interface
        1. 25.5.1.1. Properties
      2. 25.5.2. The AccessibleEditableText Interface
        1. 25.5.2.1. Property
        2. 25.5.2.2. Text manipulation methods
      3. 25.5.3. The AccessibleTable Interface
        1. 25.5.3.1. Properties
      4. 25.5.4. Relations and Extended Information
      5. 25.5.5. Implementing AccessibleAction
    6. 25.6. The Accessibility Utility Classes
      1. 25.6.1. The EventQueueMonitor Class
        1. 25.6.1.1. Constructor
        2. 25.6.1.2. Initialization
        3. 25.6.1.3. Methods
      2. 25.6.2. The AWTEventMonitor Class
        1. 25.6.2.1. Constructor
        2. 25.6.2.2. Methods
      3. 25.6.3. The SwingEventMonitor Class
        1. 25.6.3.1. Constructor
        2. 25.6.3.2. Methods
      4. 25.6.4. The TopLevelWindowListener Interface
        1. 25.6.4.1. Methods
      5. 25.6.5. The GUIInitializedListener Interface
        1. 25.6.5.1. Method
    7. 25.7. Interfacing with Accessibility
      1. 25.7.1. The Java Accessibility Helper
  29. 26. Look and Feel
    1. 26.1. Mac OS X and the Default Look-and-Feel
    2. 26.2. How Does It Work?
    3. 26.3. Key Look-and-Feel Classes and Interfaces
      1. 26.3.1. The LookAndFeel Class
        1. 26.3.1.1. Properties
        2. 26.3.1.2. Constructor
        3. 26.3.1.3. Methods
        4. 26.3.1.4. Static convenience methods
      2. 26.3.2. The UIDefaults Class
        1. 26.3.2.1. Events
        2. 26.3.2.2. Constructors
        3. 26.3.2.3. Methods
      3. 26.3.3. The UIDefaults.ActiveValue Interface
        1. 26.3.3.1. Method
        2. 26.3.3.2. Creating an ActiveValue
      4. 26.3.4. The UIDefaults.LazyValue Interface
        1. 26.3.4.1. Method
        2. 26.3.4.2. Creating a LazyValue
      5. 26.3.5. The UIResource Interface
        1. 26.3.5.1. Static BorderUIResource methods
        2. 26.3.5.2. BorderUIResource inner classes
      6. 26.3.6. The UIManager Class
        1. 26.3.6.1. LAFState
        2. 26.3.6.2. UIManager look-and-feel concepts
        3. 26.3.6.3. Look-and-feel properties file
        4. 26.3.6.4. Events
        5. 26.3.6.5. UIDefaults convenience methods
        6. 26.3.6.6. Other static methods
        7. 26.3.6.7. Changing the look-and-feel
        8. 26.3.6.8. Managing defaults
      7. 26.3.7. The UIManager.LookAndFeelInfo Class
        1. 26.3.7.1. Properties
        2. 26.3.7.2. Constructor
        3. 26.3.7.3. Method
      8. 26.3.8. The ComponentUI Class
        1. 26.3.8.1. Methods
        2. 26.3.8.2. Static method
    4. 26.4. The MultiLookAndFeel
      1. 26.4.1. Creating an Auxilliary Look-and-Feel
      2. 26.4.2. Installing the MultiLookAndFeel
    5. 26.5. Auditory Cues
    6. 26.6. Look-and-Feel Customization
      1. 26.6.1. Modification of Component Properties
      2. 26.6.2. Modification of the UI Defaults
        1. 26.6.2.1. Making global changes with defaults
      3. 26.6.3. Using Metal’s Themes
        1. 26.6.3.1. MetalTheme properties
        2. 26.6.3.2. Abstract protected methods
        3. 26.6.3.3. Black and white
        4. 26.6.3.4. Additional customization
        5. 26.6.3.5. DefaultMetalTheme font properties
        6. 26.6.3.6. Protected DefaultMetalTheme base colors
      4. 26.6.4. Use of Metal’s Client Properties
      5. 26.6.5. Replacement of Individual UI Delegates
        1. 26.6.5.1. Modifying a scrollbar
    7. 26.7. Creation of a Custom Look-and-Feel
      1. 26.7.1. The PlainLookAndFeel
      2. 26.7.2. Creating the LookAndFeel Class
        1. 26.7.2.1. Defining class defaults
        2. 26.7.2.2. Defining look-and-feel colors
        3. 26.7.2.3. Defining component defaults
      3. 26.7.3. Defining an Icon Factory
      4. 26.7.4. Defining Custom Borders
      5. 26.7.5. The BasicGraphicsUtils Class
        1. 26.7.5.1. Methods
      6. 26.7.6. Creating the Individual UI Delegates
        1. 26.7.6.1. Define a constructor
        2. 26.7.6.2. Define the factory method
        3. 26.7.6.3. Define installUI( ) and uninstallUI( ) (optional)
        4. 26.7.6.4. Define component size
        5. 26.7.6.5. Override component-specific details
        6. 26.7.6.6. Paint the component
      7. 26.7.7. Don’t Forget to Use It
      8. 26.7.8. How’s It Look?
      9. 26.7.9. One Down...
  30. 27. Swing Utilities
    1. 27.1. Utility Classes
      1. 27.1.1. The SwingUtilities Class
        1. 27.1.1.1. Constructor
        2. 27.1.1.2. Class methods
      2. 27.1.2. The SwingConstants Interface
    2. 27.2. The Timer Class
      1. 27.2.1. Properties
      2. 27.2.2. Events
      3. 27.2.3. Constructor
      4. 27.2.4. Timer Control Methods
    3. 27.3. Tooltips
      1. 27.3.1. The ToolTipManager Class
        1. 27.3.1.1. Properties
        2. 27.3.1.2. Miscellaneous methods
      2. 27.3.2. The JToolTip Class
        1. 27.3.2.1. Properties
        2. 27.3.2.2. Constructor
    4. 27.4. Rendering Odds and Ends
      1. 27.4.1. The CellRendererPane Class
      2. 27.4.2. The Renderer Interface
      3. 27.4.3. The GrayFilter Class
        1. 27.4.3.1. Constructor
        2. 27.4.3.2. Image methods
    5. 27.5. Event Utilities
      1. 27.5.1. The EventListenerList Class
        1. 27.5.1.1. Constructor
        2. 27.5.1.2. Listener methods
      2. 27.5.2. The KeyStroke Class
        1. 27.5.2.1. Properties
        2. 27.5.2.2. Key codes
        3. 27.5.2.3. Factory methods
      3. 27.5.3. The MouseInputAdapter Class
        1. 27.5.3.1. Methods
      4. 27.5.4. The SwingPropertyChangeSupport Class
        1. 27.5.4.1. Constructor
        2. 27.5.4.2. Methods
  31. 28. Swing Under the Hood
    1. 28.1. Working with Focus
      1. 28.1.1. Overview
        1. 28.1.1.1. Focus traversal
        2. 28.1.1.2. Validation
        3. 28.1.1.3. Temporary focus changes
        4. 28.1.1.4. Focus cycles
      2. 28.1.2. Using Focus Properties
      3. 28.1.3. The KeyboardFocusManager Class
        1. 28.1.3.1. Constants
        2. 28.1.3.2. Constructor
        3. 28.1.3.3. Methods
        4. 28.1.3.4. Properties
        5. 28.1.3.5. Listener lists
      4. 28.1.4. The DefaultKeyboardFocusManager Class
      5. 28.1.5. The FocusTraversalPolicy Class
      6. 28.1.6. Writing Your Own Focus Traversal Policy
    2. 28.2. Multithreading Issues in Swing
      1. 28.2.1. When Is Thread Safety an Issue?
        1. 28.2.1.1. Don’t be fooled
      2. 28.2.2. Updating Components from the Event Dispatch Thread
        1. 28.2.2.1. Methods
        2. 28.2.2.2. Managing synchronization properly
    3. 28.3. Lightweight Versus HeavyweightComponents
      1. 28.3.1. Understanding the Z-Order
      2. 28.3.2. Mixing Swing and AWT
        1. 28.3.2.1. Overlapping heavyweight and lightweight components
        2. 28.3.2.2. Heavyweight components in front of lightweight menus
        3. 28.3.2.3. Pop ups
        4. 28.3.2.4. Heavyweight components in JScrollPane
        5. 28.3.2.5. Heavyweight components inside internal frames
    4. 28.4. Painting and Repainting
      1. 28.4.1. Swing Responsibilities
      2. 28.4.2. The RepaintManager Class
        1. 28.4.2.1. Key methods
        2. 28.4.2.2. Methods
    5. 28.5. Creating Your Own Component
      1. 28.5.1. Getting Started
        1. 28.5.1.1. You should have a model and a UI delegate
      2. 28.5.2. Creating a Model
        1. 28.5.2.1. Reuse or extend existing models whenever possible
        2. 28.5.2.2. Decide on properties and create the model interface
        3. 28.5.2.3. Send events when bound properties change
        4. 28.5.2.4. Reuse the EventListenerList class
        5. 28.5.2.5. Don’t put component properties in the model
        6. 28.5.2.6. Implement the model
      3. 28.5.3. The UI Delegate
        1. 28.5.3.1. Create an abstract type class
        2. 28.5.3.2. You must implement a paint method
        3. 28.5.3.3. Be able to resize yourself
      4. 28.5.4. Creating the Component Itself
        1. 28.5.4.1. Deciding on properties
        2. 28.5.4.2. Listening to your models
        3. 28.5.4.3. Sending events when bound properties change
      5. 28.5.5. Some Final Questions
      6. 28.5.6. The Jog Shuttle: a Simple Swing Component
        1. 28.5.6.1. The component
        2. 28.5.6.2. The UI delegate
      7. 28.5.7. A Toy Using the Shuttle
  32. A. Look-and-Feel Resources
  33. B. Component Actions
    1. B.1. JButton
    2. B.2. JCheckBox
    3. B.3. JCheckBoxMenuItem
    4. B.4. JComboBox
    5. B.5. JDesktopPane
    6. B.6. JEditorPane
    7. B.7. JFormattedTextField
    8. B.8. JInternalFrame
    9. B.9. JLabel
    10. B.10. JList
    11. B.11. JMenu
    12. B.12. JMenuBar
    13. B.13. JMenuItem
    14. B.14. JOptionPane
    15. B.15. JPasswordField
    16. B.16. JPopupMenu
    17. B.17. JProgressBar
    18. B.18. JRadioButton
    19. B.19. JRadioButtonMenuItem
    20. B.20. JRootPane
    21. B.21. JScrollBar
    22. B.22. JScrollPane
    23. B.23. JSlider
    24. B.24. JSpinner
    25. B.25. JSplitPane
    26. B.26. JTabbedPane
    27. B.27. JTable
    28. B.28. JTextArea
    29. B.29. JTextField
    30. B.30. JTextPane
    31. B.31. JToggleButton
    32. B.32. JToolBar
    33. B.33. JToolTip
    34. B.34. JTree
    35. B.35. JViewport
    36. B.36. Non-JComponent Containers
    37. B.37. Auditory Feedback Actions
  34. Index
  35. About the Authors
  36. Colophon
  37. Copyright