did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780130796677

Graphic Java 2, Volume 2, Swing

by
  • ISBN13:

    9780130796677

  • ISBN10:

    0130796670

  • Edition: 3rd
  • Format: Paperback
  • Copyright: 1999-03-12
  • Publisher: Prentice Hall
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $69.99

Summary

Preface

 

 

This book has been my full-time passion for more than a year. After Sun closed its office in Colorado Springs in August of 1997, I decided to forego traditional employment to give the Graphic Java series my complete attention. I was determined that the Swing volume would be the definitive guide to Swing, which meant that it had to be the most comprehensive, accurate and insightful Swing book available. I believe that to be the case, but of course, you will be the final judge.

Before I began writing, I spent a considerable amount of effort designing a book that would be beneficial to Swing novices in addition to developers with some Swing experience. As a software developer who has used numerous object oriented GUI frameworks, I realized that the fastest way to climb a framework's learning curve is to study code examples that illustrate specific concepts. As a result, code examples are the foundation upon which this book is built; nearly 300 code examples are discussed in detail--an average of approximately one code example every 5 pages.

However, code examples in and of themselves, cannot suffice as a reference for developers who have advanced along the Swing learning curve. As a result, every Swing component discussion is accompanied by a component summary that includes class diagrams, an examination of the component's properties and events and a class summary that discusses the public and protected methods implemented by the component.

The first part of this book explores fundamental aspects of Swing including:

Swing applets and applications
  • Swing and multithreading
  • Swing's Model-View-Controller architecture
  • Pluggable Look And Feel
  • The JComponent class
  • Borders, icons and actions
Miscellaneous features including timers and Swing utilities

The second part of the book examines Swing's components in detail. Numerous code examples are discussed for every Swing component, from labels and buttons to tables, trees and the text package. For example, more than 150 pages containing 25 code examples are dedicated to the table component, and 120 pages and 20 code examples illustrate how to get the most out of the tree component.

Audience

This book assumes that the reader has a good grasp of the Java language including recent additions to the language such as inner classes. This book also assumes a rudimentary understanding of the AWT; specifically, the delegation event model and the Component and Container classes upon which all Swing components are based. See "Graphic Java 2 Mastering the JFC Volume I: AWT" for a thorough investigation of AWT infrastructure and components.

How To Use This Book

Before diving into the Swing components, it is useful to have an understanding of fundamental concepts such as Swing's Model-View-Controller (MVC) design and pluggable look and feel. The former is discussed in "Swing Component Architecture" on page 71 and the latter is covered in the "Pluggable Look and Feel" on page 317. It is also important to understand the services provided by the JComponent class, which is the ultimate superclass of all lightweight Swing components. The JComponent class is examined in "The JComponent Class" on page 123.

Component Summaries

Each Swing component is introduced with numerous code examples that illustrate various component features. Code examples are followed by component summaries, such as the JScrollPane component summary that is partially listed below.

Component summaries begin with a listing of the component's model, UI delegate, renderer and editor, in addition to the events fired by the component. If a component is a replacement for an AWT component, the AWT component is also listed.

JScrollPane
----
javax.swing.plaf.basic.BasicScrollPaneUI
----
----
PropertyChangeEvent
java.awt.ScrollPane
 

The static relationships that a component maintains with other objects are illustrated with a class diagram, such as the class diagram for the JScrollPane class shown above. Class diagrams are introduced in Appendix A, Class Diagrams .

Properties

Property tables, such as the property table for the JScrollPane class shown below, are used to communicate a component's properties. Property tables include property names, the property's data type and whether a property is boolean, bound (a property change event is fired when the property is changed), simple (no events are fired when the property is changed), constrained (changes to the property can be vetoed), or indexed (a parameter, usually an integer , is used to access the property).

Some properties can be specified when a component is instantiated, and a component may provide setter and getter methods for a property. The manner in which a property can be specified is listed in the Access column of a property table.

Property tables also include a column for property default values.

Property tables are followed by a short description of each of the properties listed in the table.

JScrollPane Properties

Property Name

Data Type

Property Type

Author Biography

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.

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.

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Excerpts

Preface This book has been my full-time passion for more than a year. After Sun closed its office in Colorado Springs in August of 1997, I decided to forego traditional employment to give the Graphic Java series my complete attention. I was determined that the Swing volume would be the definitive guide to Swing, which meant that it had to be the most comprehensive, accurate and insightful Swing book available. I believe that to be the case, but of course, you will be the final judge. Before I began writing, I spent a considerable amount of effort designing a book that would be beneficial to Swing novices in addition to developers with some Swing experience. As a software developer who has used numerous object oriented GUI frameworks, I realized that the fastest way to climb a framework's learning curve is to study code examples that illustrate specific concepts. As a result, code examples are the foundation upon which this book is built; nearly 300 code examples are discussed in detail--an average of approximately one code example every 5 pages. However, code examples in and of themselves, cannot suffice as a reference for developers who have advanced along the Swing learning curve. As a result, every Swing component discussion is accompanied by a component summary that includes class diagrams, an examination of the component's properties and events and a class summary that discusses the public and protected methods implemented by the component. The first part of this book explores fundamental aspects of Swing including: Swing applets and applications Swing and multithreading Swing's Model-View-Controller architecture Pluggable Look And Feel The JComponent class Borders, icons and actions Miscellaneous features including timers and Swing utilities The second part of the book examines Swing's components in detail. Numerous code examples are discussed for every Swing component, from labels and buttons to tables, trees and the text package. For example, more than 150 pages containing 25 code examples are dedicated to the table component, and 120 pages and 20 code examples illustrate how to get the most out of the tree component. Audience This book assumes that the reader has a good grasp of the Java language including recent additions to the language such as inner classes. This book also assumes a rudimentary understanding of the AWT; specifically, the delegation event model and the Component and Container classes upon which all Swing components are based. See "Graphic Java 2 Mastering the JFC Volume I: AWT" for a thorough investigation of AWT infrastructure and components. How To Use This Book Before diving into the Swing components, it is useful to have an understanding of fundamental concepts such as Swing's Model-View-Controller (MVC) design and pluggable look and feel. The former is discussed in "Swing Component Architecture" on page 71 and the l

Rewards Program