Graphic Java 2: Mastering the Jfc, By Geary, 3Rd Edition, Volume 2: Swing

2.6 avg rating
( 10 ratings by GoodReads )
 
9780130796677: Graphic Java 2: Mastering the Jfc, By Geary, 3Rd Edition, Volume 2: Swing

Graphic Java 2 is quite simply the most comprehensive guide to the Java Foundation Classes available. Written for experienced programmers looking for thorough and detailed explanations of the JFC libraries, Volume 2 covers all aspects of the swing framework. Swing is the long-awaited successor to the AWT's heavyweight components. It provides many components that AWT developers could previously only dream about -- or purchase -- such as Tooltips, tables, trees, sliders, a complete document framework, and more. This book provides comprehensive coverage of the Swing framework, the designs behind it, and the use of Swing components. Thousands of experienced Java developers are ready to move beyond AWT's limits. This book shows them how to do so. Together with Graphic Java Volume 1 (AWT) and Volume 3 (2D API), it gives developers all the tools they need to build professional, customizable cross-platform applications that fully leverage the new Java Foundation Classes -- and to deliver those applications fast.

"synopsis" may belong to another edition of this title.

Review:

If you're developing software that will be used by a large group of people, you need to give it a good-looking front-end--in Java 2, that means you have to use Swing. An excellent resource, Graphic Java 2: Mastering the JFC, Third Edition (Volume 2: Swing) takes on the Swing components one at a time and shows you how to incorporate them into attractive, efficient programs.

In many ways, Graphic Java 2 is a cookbook. You search the table of contents or index for a reference to the kind of problem you want to solve, then examine the author's examples for the solution (or at least some clues to it). This is the book to turn to if you're wondering how to implement the JComboBox.KeySelectionManager interface (which enables users to select items in a combo box) or compare the various ways of making the JTree component into a file browser. Those are just two of hundreds of examples in David Geary's book.

While most examples don't serve any practical purpose by themselves, they do clearly illustrate how a specific aspect of Swing works. It's easy to adapt the details presented here into your own programs. Geary shows consideration for the reader by presenting all his examples as programs that can be compiled and including them on the enclosed CD-ROM. --David Wall

From the Inside Flap:

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.

 

 

"About this title" may belong to another edition of this title.

Top Search Results from the AbeBooks Marketplace

1.

Geary, David
Published by Prentice Hall (1999)
ISBN 10: 0130796670 ISBN 13: 9780130796677
New Paperback Quantity Available: 1
Seller
Irish Booksellers
(Rumford, ME, U.S.A.)
Rating
[?]

Book Description Prentice Hall, 1999. Paperback. Book Condition: New. book. Bookseller Inventory # 0130796670

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 27.28
Convert Currency

Add to Basket

Shipping: FREE
Within U.S.A.
Destination, Rates & Speeds

2.

Geary, David
Published by Prentice Hall (1999)
ISBN 10: 0130796670 ISBN 13: 9780130796677
New Paperback Quantity Available: 1
Seller
Ergodebooks
(RICHMOND, TX, U.S.A.)
Rating
[?]

Book Description Prentice Hall, 1999. Paperback. Book Condition: New. 3. Bookseller Inventory # DADAX0130796670

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 25.07
Convert Currency

Add to Basket

Shipping: US$ 3.99
Within U.S.A.
Destination, Rates & Speeds

3.

Geary, David
Published by Prentice Hall (1999)
ISBN 10: 0130796670 ISBN 13: 9780130796677
New Softcover Quantity Available: 1
Seller
Book Deals
(Lewiston, NY, U.S.A.)
Rating
[?]

Book Description Prentice Hall, 1999. Book Condition: New. Brand New, Unread Copy in Perfect Condition. A+ Customer Service! Summary: 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. JLab. Bookseller Inventory # ABE_book_new_0130796670

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 52.84
Convert Currency

Add to Basket

Shipping: FREE
Within U.S.A.
Destination, Rates & Speeds

4.

Geary, David
Published by Prentice Hall (1999)
ISBN 10: 0130796670 ISBN 13: 9780130796677
New Paperback Quantity Available: 3
Seller
Murray Media
(North Miami Beach, FL, U.S.A.)
Rating
[?]

Book Description Prentice Hall, 1999. Paperback. Book Condition: New. Bookseller Inventory # P110130796670

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 49.87
Convert Currency

Add to Basket

Shipping: US$ 2.99
Within U.S.A.
Destination, Rates & Speeds

5.

Geary, David
Published by Pearson Education Limited, United Kingdom (1999)
ISBN 10: 0130796670 ISBN 13: 9780130796677
New Quantity Available: 1
Seller
The Book Depository US
(London, United Kingdom)
Rating
[?]

Book Description Pearson Education Limited, United Kingdom, 1999. Mixed media product. Book Condition: New. 3rd Revised edition. 224 x 173 mm. Language: English . Brand New Book. Graphic Java 2 is quite simply the most comprehensive guide to the Java Foundation Classes available. Written for experienced programmers looking for thorough and detailed explanations of the JFC libraries, Volume 2 covers all aspects of the swing framework. Swing is the long-awaited successor to the AWT s heavyweight components. It provides many components that AWT developers could previously only dream about -- or purchase -- such as Tooltips, tables, trees, sliders, a complete document framework, and more. This book provides comprehensive coverage of the Swing framework, the designs behind it, and the use of Swing components. Thousands of experienced Java developers are ready to move beyond AWT s limits. This book shows them how to do so. Together with Graphic Java Volume 1 (AWT) and Volume 3 (2D API), it gives developers all the tools they need to build professional, customizable cross-platform applications that fully leverage the new Java Foundation Classes -- and to deliver those applications fast. Bookseller Inventory # AAS9780130796677

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 60.71
Convert Currency

Add to Basket

Shipping: FREE
From United Kingdom to U.S.A.
Destination, Rates & Speeds

6.

Geary, David
Published by Prentice Hall
ISBN 10: 0130796670 ISBN 13: 9780130796677
New PAPERBACK Quantity Available: 1
Seller
Cloud 9 Books
(West Palm Beach, FL, U.S.A.)
Rating
[?]

Book Description Prentice Hall. PAPERBACK. Book Condition: New. 0130796670 New Condition. Bookseller Inventory # NEW6.0044850

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 59.99
Convert Currency

Add to Basket

Shipping: US$ 4.99
Within U.S.A.
Destination, Rates & Speeds

7.

Geary, David
Published by Pearson Education Limited, United Kingdom (1999)
ISBN 10: 0130796670 ISBN 13: 9780130796677
New Quantity Available: 1
Seller
The Book Depository
(London, United Kingdom)
Rating
[?]

Book Description Pearson Education Limited, United Kingdom, 1999. Mixed media product. Book Condition: New. 3rd Revised edition. 224 x 173 mm. Language: English . Brand New Book. Graphic Java 2 is quite simply the most comprehensive guide to the Java Foundation Classes available. Written for experienced programmers looking for thorough and detailed explanations of the JFC libraries, Volume 2 covers all aspects of the swing framework. Swing is the long-awaited successor to the AWT s heavyweight components. It provides many components that AWT developers could previously only dream about -- or purchase -- such as Tooltips, tables, trees, sliders, a complete document framework, and more. This book provides comprehensive coverage of the Swing framework, the designs behind it, and the use of Swing components. Thousands of experienced Java developers are ready to move beyond AWT s limits. This book shows them how to do so. Together with Graphic Java Volume 1 (AWT) and Volume 3 (2D API), it gives developers all the tools they need to build professional, customizable cross-platform applications that fully leverage the new Java Foundation Classes -- and to deliver those applications fast. Bookseller Inventory # AAS9780130796677

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 65.42
Convert Currency

Add to Basket

Shipping: FREE
From United Kingdom to U.S.A.
Destination, Rates & Speeds

8.

Geary, David
Published by Pearson Education Limited 1999-03-12, Harlow (1999)
ISBN 10: 0130796670 ISBN 13: 9780130796677
New Quantity Available: 1
Seller
Blackwell's
(Oxford, OX, United Kingdom)
Rating
[?]

Book Description Pearson Education Limited 1999-03-12, Harlow, 1999. multimedia item. Book Condition: New. Bookseller Inventory # 9780130796677

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 63.72
Convert Currency

Add to Basket

Shipping: US$ 5.57
From United Kingdom to U.S.A.
Destination, Rates & Speeds

9.

Geary, David
Published by Prentice-Hall (1999)
ISBN 10: 0130796670 ISBN 13: 9780130796677
New Softcover Quantity Available: 1
Seller
Rating
[?]

Book Description Prentice-Hall, 1999. Book Condition: New. Bookseller Inventory # TB9780130796677

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 72.19
Convert Currency

Add to Basket

Shipping: US$ 5.35
From Germany to U.S.A.
Destination, Rates & Speeds

10.

Geary, David
ISBN 10: 0130796670 ISBN 13: 9780130796677
New Quantity Available: 1
Seller
Castle Rock
(Pittsford, NY, U.S.A.)
Rating
[?]

Book Description Book Condition: Brand New. Book Condition: Brand New. Bookseller Inventory # 97801307966771.0

More Information About This Seller | Ask Bookseller a Question

Buy New
US$ 79.98
Convert Currency

Add to Basket

Shipping: US$ 3.99
Within U.S.A.
Destination, Rates & Speeds

There are more copies of this book

View all search results for this book