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
Table of contents
- Java Swing, 2nd Edition
- A Note Regarding Supplemental Files
- Preface
- 1. Introducing Swing
- 2. Jump-Starting a Swing Application
-
3. Swing Component Basics
- 3.1. Understanding Actions
- 3.2. Graphical Interface Events
- 3.3. Graphics Environments
- 3.4. Sending Change Events in Swing
-
3.5. The JComponent Class
- 3.5.1. Inherited Properties
- 3.5.2. Common Methods
- 3.5.3. JComponent Properties
- 3.5.4. UI Delegates and UIClassIDs
- 3.5.5. Invalidating and Repainting
- 3.5.6. Position, Size, and Alignment
- 3.5.7. Adding Borders
- 3.5.8. Working with Tooltips
- 3.5.9. Client Properties
- 3.5.10. Double Buffering
- 3.5.11. Serialization
- 3.5.12. The DebugGraphics Class
- 3.5.13. Focus and Focus Cycle Methods
- 3.5.14. Keyboard Events
- 3.5.15. Accessibility
- 3.5.16. Events
- 3.5.17. Constructor
- 3.5.18. Graphics Methods
- 3.5.19. Focus Methods
- 3.5.20. Tooltip Methods
- 3.5.21. Client Properties Methods
- 3.5.22. Miscellaneous Methods
- 3.6. Responding to Keyboard Input
- 4. Labels and Icons
- 5. Buttons
- 6. Bounded-Range Components
-
7. Lists, Combo Boxes, and Spinners
- 7.1. Lists
- 7.2. Representing List Data
- 7.3. Handling Selections
- 7.4. Displaying Cell Elements
- 7.5. The JList Class
- 7.6. Combo Boxes
- 7.7. The JComboBox Class
- 7.8. Spinners
- 7.9. Spinner Models
- 7.10. Spinner Editors
-
8. Swing Containers
- 8.1. A Simple Container
- 8.2. The Root Pane
- 8.3. Basic RootPaneContainers
- 8.4. The JFrame Class
- 8.5. The JWindow Class
- 8.6. The JApplet Class
-
9. Internal Frames
- 9.1. Simulating a Desktop
-
9.2. The JInternalFrame Class
- 9.2.1. Properties
- 9.2.2. Events
- 9.2.3. Constants
- 9.2.4. Constructors
- 9.2.5. JLayeredPane Methods
- 9.2.6. Miscellaneous Public Methods
- 9.2.7. Use of the Glass Pane
- 9.2.8. The Metal Look-and-Feel JInternalFrame.isPalette Client Property
- 9.2.9. The JInternalFrame.JDesktopIcon Class
- 9.2.10. The InternalFrameEvent Class
- 9.2.11. The InternalFrameListener Interface
- 9.2.12. The InternalFrameAdapter Class
- 9.3. The JDesktopPane Class
- 9.4. The DesktopManager Interface
- 9.5. Building a Desktop
- 10. Swing Dialogs
-
11. Specialty Panes and Layout Managers
- 11.1. The JSplitPane Class
- 11.2. The JScrollPane Class
- 11.3. The JTabbedPane Class
- 11.4. Layout Managers
- 11.5. The SpringLayout Class
- 11.6. Other Panes
-
12. Chooser Dialogs
- 12.1. The JFileChooser Class
- 12.2. The File Chooser Package
- 12.3. The Color Chooser
- 12.4. The JColorChooser Class
- 12.5. Developing a Custom Chooser Panel
- 12.6. Developing a Custom Preview Panel
- 12.7. Developing a Custom Dialog
-
13. Borders
- 13.1. Introducing Borders
- 13.2. Painting Borders Correctly
- 13.3. Swing Borders
- 13.4. Creating Your Own Border
-
14. Menus and Toolbars
- 14.1. Introducing Swing Menus
- 14.2. Menu Bar Selection Models
- 14.3. The JMenuBar Class
-
14.4. The JMenuItem Class
- 14.4.1. Menu Item Shortcuts
- 14.4.2. Images
- 14.4.3. Event Handling
- 14.4.4. Properties
- 14.4.5. Constructors
- 14.4.6. Events
- 14.4.7. Method
- 14.4.8. Menu Element Interface
- 14.4.9. The MenuDragMouseEvent Class
- 14.4.10. The MenuDragMouseListener Interface
- 14.4.11. The MenuKeyEvent Class
- 14.4.12. The MenuKeyListener Interface
- 14.5. The JPopupMenu Class
- 14.6. The JMenu Class
-
14.7. Selectable Menu Items
- 14.7.1. The JCheckBoxMenuItem Class
- 14.7.2. Using Checkbox Menu Items
- 14.7.3. The JRadioButtonMenuItem Class
- 14.7.4. Enforcing Mutual Exclusion
- 14.7.5. The JSeparator Class
- 14.7.6. Using a Separator Outside of a Menu
- 14.7.7. The MenuElement Interface
- 14.7.8. Making Arbitrary Components into Menu Elements
- 14.8. Toolbars
-
15. Tables
-
15.1. The JTable Class
- 15.1.1. Table Columns
- 15.1.2. Properties
- 15.1.3. Events
- 15.1.4. Constants
- 15.1.5. Constructors
- 15.1.6. Other Interesting Methods
- 15.1.7. The TableColumn Class
- 15.1.8. The TableColumnModel Interface
- 15.1.9. The DefaultTableColumnModel Class
- 15.1.10. The TableColumnModelEvent Class
- 15.1.11. The TableColumnModelListener Interface
- 15.2. Implementing a Column Model
- 15.3. Table Data
- 15.4. Selecting Table Entries
- 15.5. Rendering Cells
- 15.6. Editing Cells
- 15.7. Next Steps
-
15.1. The JTable Class
- 16. Advanced Table Examples
-
17. Trees
- 17.1. A Simple Tree
- 17.2. Tree Models
- 17.3. The JTree Class
- 17.4. Tree Nodes and Paths
- 17.5. Tree Selections
- 17.6. Tree Events
- 17.7. Rendering and Editing
- 17.8. What Next?
-
18. Undo
- 18.1. The Swing Undo Facility
-
18.2. The UndoManager Class
- 18.2.1. A Codeless Example
- 18.2.2. Transformer?
- 18.2.3. Properties
- 18.2.4. Constructor
- 18.2.5. UndoableEditListener Method
- 18.2.6. UndoableEdit Methods
- 18.2.7. Public Methods
- 18.2.8. Protected Methods
- 18.2.9. Using an Undo Manager
- 18.2.10. Understanding the UndoManager
- 18.2.11. The StateEditable Interface
- 18.2.12. The StateEdit Class
- 18.2.13. The UndoableEditSupport Class
- 18.2.14. Using Undoable Edit Support
- 18.2.15. The CannotRedoException Class
- 18.2.16. The CannotUndoException Class
- 18.3. Extending UndoManager
- 19. Text 101
-
20. Formatted Text Fields
- 20.1. The JFormattedTextField Class
- 20.2. Handling Numerics
- 20.3. The DefaultFormatter Class
- 20.4. The MaskFormatter Class
- 20.5. The InternationalFormatter Class
- 20.6. The DateFormatter Class
- 20.7. The NumberFormatter Class
- 20.8. The DefaultFormatterFactory Class
- 20.9. Formatting with Regular Expressions
- 20.10. The InputVerifier Class
-
21. Carets, Highlighters, and Keymaps
- 21.1. Carets
-
21.2. Highlighters
- 21.2.1. The Highlighter.HighlightPainter Interface
- 21.2.2. A Custom HighlightPainter
- 21.2.3. The Highlighter.Highlight Interface
- 21.2.4. The Highlighter Interface
- 21.2.5. Adding Multiple Highlights
- 21.2.6. The LayeredHighlighter Class
- 21.2.7. The DefaultHighlighter Class
- 21.2.8. The DefaultHighlighter.DefaultHighlightPainter Class
- 21.3. Keymaps
-
22. Styled Text Panes
- 22.1. The JTextPane Class
- 22.2. AttributeSets and Styles
- 22.3. The Document Model
-
22.4. Document Events
- 22.4.1. The DocumentListener Interface
- 22.4.2. The DocumentEvent Interface
- 22.4.3. The DocumentEvent.EventType Class
- 22.4.4. The DocumentEvent.ElementChange Interface
- 22.4.5. The ElementIterator Class
- 22.4.6. The Segment Class
- 22.4.7. The AbstractDocument.Content Interface
- 22.4.8. The StringContent Class
- 22.4.9. The GapContent Class
- 22.4.10. Undo Event Example
- 22.4.11. The BadLocationException Class
- 22.4.12. The Position Interface
- 22.4.13. The Position.Bias Class
-
22.5. Views
- 22.5.1. The ViewFactory Interface
-
22.5.2. The View Class
- 22.5.2.1. Float coordinates
- 22.5.2.2. Shape versus Rectangle
- 22.5.2.3. Span and allocation
- 22.5.2.4. Axis
- 22.5.2.5. Bias
- 22.5.2.6. Properties
- 22.5.2.7. Constructor
- 22.5.2.8. Constants
- 22.5.2.9. Abstract methods
- 22.5.2.10. Translation methods
- 22.5.2.11. Break methods
- 22.5.2.12. Tree management methods
- 22.5.2.13. Layout methods
- 22.5.2.14. Update methods
- 22.5.3. The View Classes
- 22.5.4. The TabExpander Interface
- 22.5.5. The TabableView Interface
- 22.5.6. The Utilities Class
- 22.6. The DocumentFilter Class
- 22.7. The NavigationFilter Class
-
23. Editor Panes and Editor Kits
- 23.1. The JEditorPane Class
-
23.2. Overview of the Editor Kits
- 23.2.1. The EditorKit Class
- 23.2.2. The TextAction Class
- 23.2.3. The DefaultEditorKit Class
- 23.2.4. Useful Actions
- 23.2.5. A Simple Text Editor
- 23.2.6. The StyledEditorKit Class
-
23.2.7. The StyledEditorKit.StyledTextAction Class
- 23.2.7.1. Constructor
- 23.2.7.2. Protected methods
- 23.2.7.3. The StyledEditorKit.FontFamilyAction class
- 23.2.7.4. The StyledEditorKit.FontSizeAction class
- 23.2.7.5. The StyledEditorKit.ForegroundAction class
- 23.2.7.6. The StyledEditorKit.AlignmentAction class
- 23.2.7.7. The StyledEditorKit.BoldAction class
- 23.2.7.8. The StyledEditorKit.ItalicAction class
- 23.2.7.9. The StyledEditorKit.UnderlineAction class
- 23.2.8. A Better Editor
- 23.3. HTML and JEditorPane
- 23.4. Hyperlink Events
- 23.5. The HTMLEditorKit Class
- 23.6. Extending HTMLEditorKit
- 23.7. Editing HTML
- 23.8. Writing HTML
- 23.9. Reading HTML
- 23.10. A Custom EditorKit
-
24. Drag and Drop
- 24.1. What Is Drag and Drop?
-
24.2. The Drop API
- 24.2.1. The DropTarget Class
- 24.2.2. The DnDConstants Class
- 24.2.3. The DropTargetContext Class
- 24.2.4. The DropTargetListener Interface
- 24.2.5. The DropTargetAdapter Class
- 24.2.6. The DropTargetEvent Class
- 24.2.7. The DropTargetDragEvent Class
- 24.2.8. The DropTargetDropEvent Class
- 24.2.9. Drop Example
- 24.2.10. Transferable Contents
- 24.2.11. The TransferHandler Class
- 24.3. The Drag Gesture API
-
24.4. The Drag API
- 24.4.1. The DragSource Class
- 24.4.2. The DragSourceContext Class
- 24.4.3. The DragSourceListener Interface
- 24.4.4. The DragSourceMotionListener Interface
- 24.4.5. The DragSourceAdapter Class
- 24.4.6. Drag Source Events
- 24.4.7. The DragSourceDragEvent Class
- 24.4.8. The DragSourceDropEvent Class
- 24.4.9. Completing the Gesture
- 24.5. Rearranging Trees
- 24.6. Finishing Touches
-
25. Programming with Accessibility
- 25.1. How Accessibility Works
- 25.2. The Accessibility Package
- 25.3. Other Accessible Objects
- 25.4. Types of Accessibility
- 25.5. Classes Added in SDK 1.3 and 1.4
- 25.6. The Accessibility Utility Classes
- 25.7. Interfacing with Accessibility
-
26. Look and Feel
- 26.1. Mac OS X and the Default Look-and-Feel
- 26.2. How Does It Work?
- 26.3. Key Look-and-Feel Classes and Interfaces
- 26.4. The MultiLookAndFeel
- 26.5. Auditory Cues
- 26.6. Look-and-Feel Customization
- 26.7. Creation of a Custom Look-and-Feel
- 27. Swing Utilities
-
28. Swing Under the Hood
- 28.1. Working with Focus
- 28.2. Multithreading Issues in Swing
- 28.3. Lightweight Versus HeavyweightComponents
- 28.4. Painting and Repainting
-
28.5. Creating Your Own Component
- 28.5.1. Getting Started
-
28.5.2. Creating a Model
- 28.5.2.1. Reuse or extend existing models whenever possible
- 28.5.2.2. Decide on properties and create the model interface
- 28.5.2.3. Send events when bound properties change
- 28.5.2.4. Reuse the EventListenerList class
- 28.5.2.5. Don’t put component properties in the model
- 28.5.2.6. Implement the model
- 28.5.3. The UI Delegate
- 28.5.4. Creating the Component Itself
- 28.5.5. Some Final Questions
- 28.5.6. The Jog Shuttle: a Simple Swing Component
- 28.5.7. A Toy Using the Shuttle
- A. Look-and-Feel Resources
-
B. Component Actions
- B.1. JButton
- B.2. JCheckBox
- B.3. JCheckBoxMenuItem
- B.4. JComboBox
- B.5. JDesktopPane
- B.6. JEditorPane
- B.7. JFormattedTextField
- B.8. JInternalFrame
- B.9. JLabel
- B.10. JList
- B.11. JMenu
- B.12. JMenuBar
- B.13. JMenuItem
- B.14. JOptionPane
- B.15. JPasswordField
- B.16. JPopupMenu
- B.17. JProgressBar
- B.18. JRadioButton
- B.19. JRadioButtonMenuItem
- B.20. JRootPane
- B.21. JScrollBar
- B.22. JScrollPane
- B.23. JSlider
- B.24. JSpinner
- B.25. JSplitPane
- B.26. JTabbedPane
- B.27. JTable
- B.28. JTextArea
- B.29. JTextField
- B.30. JTextPane
- B.31. JToggleButton
- B.32. JToolBar
- B.33. JToolTip
- B.34. JTree
- B.35. JViewport
- B.36. Non-JComponent Containers
- B.37. Auditory Feedback Actions
- Index
- About the Authors
- Colophon
- Copyright
Product information
- Title: Java Swing, 2nd Edition
- Author(s):
- Release date: November 2002
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596004088
You might also like
book
Modern Software Engineering: Doing What Works to Build Better Software Faster
Improve Your Creativity, Effectiveness, and Ultimately, Your Code In Modern Software Engineering, continuous delivery pioneer David …
book
Java Coding Problems
Develop your coding skills by exploring Java concepts and techniques such as Strings, Objects and Types, …
book
Clean Code: A Handbook of Agile Software Craftsmanship
Even bad code can function. But if code isn’t clean, it can bring a development organization …
book
Test Driven Development: By Example
Quite simply, test-driven development is meant to eliminate fear in application development. While some fear is …