Book description
The JFC Swing Tutorial is back, fully revised and updated to include the latest revisions to the JFC Swing API and the Java™ 2 platform. In this book, authors and Java experts Kathy Walrath, Mary Campione, Alison Huml, and Sharon Zakhour—working closely with the Sun Microsystems Swing team—explore the ins and outs of creating GUIs with Swing components.
This task-oriented, example-driven tutorial allows you to create user interfaces that work without change on multiple platforms, appearing and performing as well as or better than native interfaces. Leveraging the full power of the latest edition of the Java 2 platform, the authors bring the art of GUI creation to life with content new to this edition. This includes an easy-to-use tabbed reference section, new introductory chapters, and coverage of newer features such as JSpinner, JFormattedTextField, JProgressBar, mouse wheel support, the rearchitected focus subsystem, and improved support for drag and drop.
Coverage includes:
Introductory material for developers getting started with Swing, including sections on basic components such as text fields, labels, and buttons, as well as on using images
The latest advice from the Swing team about thread safety
Advanced Swing material, including changing key bindings, manipulating the focus, using data models, and adding painting code that uses the powerful Java 2D™ API
How-to discussions on using individual components and containers, including advanced components such as tables, trees, and text editors
Over 150 complete, working code examples
For the novice or experienced Java developer looking to create robust, powerful, and visually stunning GUIs, The JFC Swing Tutorial, Second Edition, is an indispensable tutorial and reference.
Table of contents
- Copyright
- The Java™ Series
- Preface
- Before You Start
- 1. Getting Started with Swing
- 2. Learning Swing by Example
-
3. Using Swing Components
- A Visual Index to Swing Components
- Using HTML in Swing Components
- Using Top-Level Containers
- Using Models
- The JComponent Class
-
Using Text Components
- Text Component Features
- The Text Component API
- Summary
- Questions and Exercises
- Example Programs
-
4. Laying Out Components within a Container
- A Visual Guide to Layout Managers
-
Using Layout Managers
- Setting the Layout Manager
- Adding Components to a Container
- Providing Size and Alignment Hints
- Putting Space between Components
- Setting the Container's Orientation
-
Choosing a Layout Manager
- Scenario: You need to display a component in as much space as it can get.
- Scenario: You need to display a few components in a compact row at their natural size.
- Scenario: You need to display a few components of the same size in rows and columns.
- Scenario: You need to display a few components in a row or column, possibly with varying amounts of space between them, custom alignment, or custom component sizes.
- Scenario: You need to display aligned columns, as in a form-like interface where a column of labels is used to describe text fields in an adjacent column.
- Scenario: You have a complex layout with many components.
- How Layout Management Works
- Creating a Custom Layout Manager
- Doing without a Layout Manager (Absolute Positioning)
- Summary
- Questions and Exercises
- Example Programs
- 5. Writing Event Listeners
- 6. Performing Custom Painting
-
7. Components Reference
- How to Make Applets
- How to Use Buttons
- How to Use Check Boxes
- How to Use Color Choosers
- How to Use Combo Boxes
- How to Make Dialogs
- How to Use Editor Panes and Text Panes
- How to Use File Choosers
-
How to Use Formatted Text Fields
- Creating and Initializing Formatted Text Fields
- Setting and Getting the Field's Value
- Specifying Formats
- Using MaskFormatter
-
Specifying Formatters and Using Formatter Factories
- Use the JFormattedTextField constructor that takes a Format argument.
- Use the JFormattedTextField constructor that takes a JFormattedTextField. AbstractFormatter argument.
- Set the value of a formatted text field that has no format, formatter, or formatter factory specified.
- Make the formatted text field use a formatter factory that returns customized formatter objects.
- The Formatted Text Field API
- Examples That Use Formatted Text Fields
- How to Make Frames (Main Windows)
-
How to Use Internal Frames
- Internal Frames versus Regular Frames
-
Rules of Using Internal Frames
- You must set the size of the internal frame.
- As a rule, you should set the location of the internal frame.
- To add components to an internal frame, add them to its content pane.
- Dialogs that are internal frames should be implemented using JOptionPane or JInternalFrame, not JDialog.
- You must add an internal frame to a container.
- You need to call show or setVisible on internal frames.
- Internal frames fire internal frame events, not window events.
- The Internal Frame API
- Examples That Use Internal Frames
- How to Use Labels
- How to Use Layered Panes
- How to Use Lists
- How to Use Menus
- How to Use Panels
- How to Use Password Fields
- How to Use Progress Bars
- How to Use Radio Buttons
- How to Use Root Panes
- How to Use Scroll Panes
- How to Use Separators
- How to Use Sliders
- How to Use Spinners
- How to Use Split Panes
- How to Use Tabbed Panes
-
How to Use Tables
- Creating a Simple Table
- Adding a Table to a Container
- Setting and Changing Column Widths
- Detecting User Selections
- Creating a Table Model
- Detecting Data Changes
- Concepts: Editors and Renderers
- Using a Combo Box as an Editor
- Using an Editor to Validate User-Entered Text
- Using Other Editors
- Using Custom Renderers
- Specifying Tool Tips for Cells
- Specifying Tool Tips for Column Headers
- Sorting and Otherwise Manipulating Data
- The Table API
- Examples That Use Tables
- How to Use Text Areas
- How to Use Text Fields
- How to Use Tool Bars
- How to Use Tool Tips
- How to Use Trees
- 8. Layout Manager Reference
-
9. Other Swing Features Reference
- How to Use Actions
- How to Support Assistive Technologies
- How to Use Borders
-
How to Use Drag and Drop and Data Transfer
- A Visual Guide to Drag-and-Drop Cursor Icons
- Introduction to Data Transfer Support
- A Simple Example: Adding DnD to JLabel
- Extending Default DnD Support
- Specifying the Data Format
- Importing a New Flavor: Color
- Replacing Default Support: Color and Text
- Importing a New Flavor: Files
- Data Transfer with a Custom Component
- Data Transfer with a Custom DataFlavor
- Adding Cut/Copy/Paste Support
- The Data Transfer API
- Examples That Use Data Transfer
- How to Use the Focus Subsystem
- How to Use Icons
- How to Use Key Bindings
- How to Set the Look and Feel
- How to Use Threads
- How to Use Timers
-
10. Event Listeners Reference
- How to Write an Action Listener
- How to Write a Caret Listener
- How to Write a Change Listener
- How to Write a Component Listener
- How to Write a Container Listener
- How to Write a Document Listener
- How to Write a Focus Listener
- How to Write an Internal Frame Listener
- How to Write an Item Listener
- How to Write a Key Listener
- How to Write a List Data Listener
- How to Write a List Selection Listener
- How to Write a Mouse Listener
- How to Write a Mouse-Motion Listener
- How to Write a Mouse Wheel Listener
- How to Write a Property-Change Listener
- How to Write a Table Model Listener
- How to Write a Tree Expansion Listener
- How to Write a Tree Model Listener
- How to Write a Tree Selection Listener
- How to Write a Tree-Will-Expand Listener
- How to Write an Undoable Edit Listener
- How to Write Window Listeners
- Troubleshooting Reference
- The JFC Swing Tutorial CD
Product information
- Title: JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition
- Author(s):
- Release date: February 2004
- Publisher(s): Addison-Wesley Professional
- ISBN: 9780201914672
You might also like
book
Core SWING advanced programming
8329B-3 The experienced developer's guide to the Swing classes! Core Swing helps you deliver the sophisticated …
book
The Java™ Tutorial Fourth Edition: A Short Course on the Basics
A hands-on guide to the Java programming language, is perfect for any developer looking for a …
book
Rich Client Programming: Plugging into the NetBeans Platform
The open-source NetBeans Platform is an extraordinarily powerful framework for building "write once, run anywhere" rich …
book
Java 2D Graphics
One weakness of Java has been its graphics capabilities. Java 1.0 and 1.1 only included simple …