Graphic Java 2, Volume 2, Swing / Edition 3

Other Format (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $1.99
Usually ships in 1-2 business days
(Save 97%)
Other sellers (Other Format)
  • All (32) from $1.99   
  • New (2) from $73.88   
  • Used (30) from $1.99   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$73.88
Seller since 2011

Feedback rating:

(871)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
Brand new and unread! Join our growing list of satisfied customers!

Ships from: Phoenix, MD

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
$73.89
Seller since 2014

Feedback rating:

(2)

Condition: New
New

Ships from: Idyllwild, CA

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
Page 1 of 1
Showing All
Close
Sort by

Overview

7966G-2

Master the Java Foundation Classes with Graphic Java 2, the most complete and comprehensive guide to the AWT, Swing, and the 2D API

VOLUME 2: SWING (This is a 2 Volume set)

Swing gives Java application programmers world-class tools for building professional, customizable cross-platform GUIs. This comprehensive reference by former Sun engineer David Geary shows experienced programmers how to take full advantage of Swing's power. Practical explanations and robust code examples provide the resources you need to build Java applications with sophisticated graphical user interfaces.

Graphic Java is the one exhaustive reference that contains everything you need to know about Swing. In depth explanations are coupled with class diagrams and code examples for all of the key components, including:

  • Buttons and labels
  • Progress bars and sliders
  • Frames, windows, and dialogs
  • Internal frames and desktop panes
  • Color and file choosers
  • Menus and toolbars
  • Lists and combo boxes
  • Text components
  • Tables and trees

You'll discover the key design considerations associated with Swing development, including Swing's object-oriented idioms and design patterns, and the pluggable look and feel architecture. You will understand how to use the Swing components, but more importantly you will have an understanding of how the components are designed and how they fit together within the Swing framework.


This is the second volume of the excellent four-volume set of programming guides and references for graphic Java. The first comprehensive volume is Graphic Java Mastering the JFC 1.2, Volume I AWT, Third Edition. It gives you extensive information about the latest changes to the Abstract Window Toolkit (AWT) API. Volume II (this volume) is a comprehensive guide and reference for the Swing framework. Please keep in mind that this set of programming guides is not for Java novices. You should be comfortable with the Java language and application programming concepts at an intermediate to advanced level. Also remember that JDK 1.2 has undergone a name change, it is now formally known as the Java 2 Platform.

Read More Show Less

Product Details

  • ISBN-13: 9780130796677
  • Publisher: Prentice Hall
  • Publication date: 3/12/1999
  • Series: Sun Microsystems Press Series
  • Edition description: 3RD BK&CDR
  • Edition number: 3
  • Pages: 1600
  • Product dimensions: 7.10 (w) x 9.20 (h) x 3.20 (d)

Meet the Author

David Gearywas lead engineer for the user interface toolkit for JavaSoft's Java Management API. He has been developing GUIs and using object-oriented technology since 1984, including C++, Smalltalk, Eiffel, Objective-C and now Java. He is currently an independent Java consultant.

Read More Show Less

Read an Excerpt


Chapter 19: Tables

Methods

Cell Editors

public TableCellEditor getCellEditor( )
public void setCellEditor(TableCellEditor)

A table column's cell editor can be set anytime after a column is constructed. The cellEditor property is a simple property, which means that a property change event is not fired when the cell editor is set. Notice that this is in contrast to the cellRenderer property, which is a bound property.

Cell Renderers

public TableCellRenderer getCellRenderer( )
public void setCellRenderer(TableCellRenderer)

A table column's cell renderer can also be set anytime after a column is constructed. The cellRenderer property is a bound property, which means that a property change event is fired when the cell editor is set. Notice that this is in contrast to the cellEditor property, which is not a bound property.

Header Renderer

public TableCellRenderer getHeaderRenderer( )
public void setHeaderRenderer(TableCellRenderer)

protected TableCellRenderer createDefaultHeaderRenderer( )

Unlike column cells, the JTable class does not provide default renderers for column headers. As a result, TableColumn.setHeaderRenderer ( ) throws an exception if passed a null renderer. The headerRenderer property is a bound property.

The createDefaultHeaderRenderer method creates a header renderer that table columns are fitted with by default. The renderer extends DefaultTableCellRenderer (which extends JLabel) and renders the value returned from the header value's toString method.

Header Value

public Object getHeaderValue( )
public void setHeaderValue(Object)

A table column's header value is the object displayed by the column's header renderer. By default, column header values are initialized with table column names. The headerValue property is a bound property.

Property Change Listeners

public synchronized void addPropertyChangeListener(PropertyChangeListener)
public synchronized void removePropertyChangeListener(PropertyChangeListener)

TableColumn fires property change events when its bound properties are modified. The methods listed above allow listeners to be added and removed from the table column.

Preferred/Minimum/Maximum Widths

public int getWidth( )
public int getMaxWidth( )
public int getMinWidth( )
public int getPrefeffedWidth( )
public void setMaxWidth(int)
public void setMinWidth(int)
public void setPreferredWidth(int)
public void setWidth(int)

The methods above are accessors for a table column's actual, minimum, maximum, and preferred widths.

Like components, columns are sized by another object (JTable). Unlike components, whose minimum, maximum, and preferred sizes can be ignored by layout managers, the JTable class always takes column widths into account when sizing columns - a table column will never be sized smaller than its minimum width or wider than its maximum width.

Because table columns are sized by the JTab1e class, setting the actual width of a column with the setWidth method is typically a temporary change.

Identifier / Model Index / Resizable

public Object getIdentifier( )
public int getModelIndex( )
public boolean getResizable( )

public void setIdentifier(Object)
public void setModelIndex(int)
public void setResizable(boolean)

The methods listed above are accessors for a table column's identifier, model index, and resizability (or lack thereof).

Note: As of Swing1.1 FCS, the setResizable method has no effect; table columns are always resizable....

Read More Show Less

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.

Read More Show Less

Preface

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

Access

Default

columnHeader

JViewport

B

SG

null

columnHeaderView

Component

B

S

null

corner

Component

IB

SG

null

horizontalScrollbar

JScrollBar

B

SG

----

horizontalScrollbarPolicy

int

B

CSG

As needed

rowHeader

JViewport

B

SG

null

rowHeaderView

Component

B

S

null

verticalScrollbar

JScrollBar

B

SG

----

verticalScrollbarPolicy

int

B

CSG

As needed

viewport

JViewport

B

SG

JViewport

viewportBorder

Border

B

SG

null

viewportView

Component

B

CSG

null

columnHeader -- An instance of JViewport for the column header.

columnHeaderView -- An instance of Component used as the column header viewport's view.

corner -- A component that is displayed in one of the scrollpane's corners. The corner is specified by one of the following strings:

ScrollPaneConstants.UPPER_LEFT_CORNER
  • ScrollPaneConstants.LOWER_LEFT_CORNER
  • ScrollPaneConstants.UPPER_RIGHT_CORNER
ScrollPaneConstants.LOWER_RIGHT_CORNER

horizontalScrollbar -- The horizontal scrollbar used by the scrollpane. The scrollbar is an instance of JScrollPane.ScrollBar , an extension of JScrollBar that takes into account whether the view contained in the scrollpane implements the Scrollable interface.

The remaining property descriptions for the JScrollPane class are omitted.

Events

Code examples are presented that illustrate event handling for a component. For example, the Tree chapter provides five code examples that illustrate handling of tree mouse, editing, selection, and expansion events.

Class Summaries

Each component summary concludes with a class summary that provides descriptions of the component's constructors and methods, such as the class summary for the JScrollPane class listed below.

JScrollPane
JComponent
ScrollPaneConstants, javax.accessibility.Accessible
public JScrollPane()

public JScrollPane(int vsbPolicy, int hsbPolicy)

public JScrollPane(Component view)

public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)

JScrollPane provides four constructors. The integer values passed to JScrollPane constructors represent the vertical and horizontal scrollbar display policies, in that order. The component passed to the constructors is used as the viewport's view, meaning it is the component that is scrolled by the scrollpane.

The no-argument constructor constructs a scrollpane with a null component for the viewport's view, and scrollbar display policies that display both the horizontal and vertical scrollbars as needed.

Creation Methods

public JScrollBar createHorizontalScrollBar()

public JScrollBar createVerticalScrollBar()

protected JViewport createViewport()

Like most Swing components, JScrollPane provides create... methods that create its subcomponents. Unlike most Swing components however, JScrollPane implements the methods that create its scrollbars as public instead of protected because the methods are invoked from the scrollpane's UI delegate.

The createHorizontalScrollBar and createVerticalScrollBar methods both return instances of JScrollPane.ScrollBar , which is an extension of JScrollBar that takes into account whether the scrollpane's view implements the Scrollable interface. See Interface Summary 13-2 on page 779 for more information on the Scrollable interface.

The createViewport method returns an instance of JViewport that is used as the scrollpane's default viewport.

As with all Swing components that implement create... methods, the methods can be overridden in extension classes to replace the default sub-components with custom versions.

The remaining method descriptions for the JScrollPane class are omitted.

Swing Bugs

Swing has come a long way in terms of quality. The early beta releases contained numerous bugs, many of which have subsequently been fixed. However, like any software, Swing still has its share of bugs. Throughout this book, I have tried to point out as many bugs as possible so that developers can avoid the frustration of debugging code only to discover that a problem is due to a Swing bug.

It is also important to keep in mind that this book is based on Swing 1.1 FCS. As we went to press, a 1.1.1 version of Swing was released that was mostly a bug fix release. Therefore, it is a certainty that some of the bugs cited in this book will have been fixed by the time this book is on the shelves.

Using the CD-ROM

The CD in the back of the book contains the following:

1.1.7 JDK and Swing 1.1.1
  • 1.2 JDK and Swing 1.1 FCS
Code examples from this book
Swing and the JDK

As mentioned previously, Swing 1.1.1 is mostly a bug fix release. Swing 1.1.1 does not work with the 1.2 JDK, and therefore the 1.1.7 JDK is included on the CD. Swing 1.1 FCS works with both the 1.1.7 and 1.2 versions of the JDK.

Code Examples from the Book

All of the code examples in this book that are accompanied by a CD-ROM icon are included on the CD in the back of the book. Figure P-1 shows the directory structure for the code examples. A directory exists for every chapter in the book, and subdirectories are included for each example, which should make it trivial to locate examples. For instance, Example 3-1 on page 91 can be found in the chapters/3/1 directory.

Every example is compiled and ready to run. Some of the directories representing code examples contain a README.txt file if the examples exhibit bugs or have been modified from their listing in the book.

The CD also contains two versions of the GridBagLab application that comes with "Graphic Java 2 Mastering the JFC Volume I: AWT." One version uses external windows and another uses Swing internal frames. The application provides an example of a fairly complete Swing application and illustrates the use of Swing internal frames. Additionally, the application can be used to explore the intricacies of the GridBagLayout layout manager.

Applets Vs. Applications

Most of the code examples discussed in this book are applets, but a fair percentage of examples are applications. Applications are typically implemented instead of applets either because files are manipulated or dialogs are shown--applets have restricted access to files, and under JDK 1.2 dialogs displayed from an applet contain a warning string. Sometimes applications are implemented instead of applets simply for the sake of variety. Nearly all of the applications discussed in this book that do not manipulate files can easily be rewritten as applets.

Conventions Used in This Book

Table P-1 shows the coding conventions used in this book.

Coding Conventions

Convention

Example

Class names have initial capital letters.

public class ClassName

Method names have initial lower case and the rest of the words have an initial capital letter.

getLength()

Variable names have initial lower case and the rest of the words have an initial capital letter.

private int length

private int bufferLength

Note that, for the most part, methods are referred to without their arguments; however, arguments are included when the discussion warrants them.

Table P-2 shows the typographic conventions used in this book.

Typographic Conventions

Typeface or Symbol

Description

Indicates that the accompanying code, command, or file is available on the CD that accompanies this book.

courier

Indicates a command, file name, class name, method, argument, Java keyword, HTML tag, file content, or code excerpt.

bold courier

Indicates a sample command-line entry.

italics

Indicates definitions, emphasis, a book title, or a variable that should be replaced with a valid value.


Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)