Errata

Java Swing

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed
Page 28
Code Listing -

ToolbarFrame4.java;

NOW READS:
ToolbarFrame3.java

public class ToolbarFrame4 extends Frame {

NOW READS:
public class ToolbarFrame3 extends Frame {

public ToolbarFrame4() {

NOW READS:
public ToolbarFrame3() {

Anonymous    May 01, 2004
Printed
Page 29
bottom of the page

public static void main(String args[]) {
ToolbarFrame4 tf4 = new ToolbarFrame4();
tf4.setVisible(true);

NOW READS:
public static void main(String args[]) {
ToolbarFrame3 tf3 = new ToolbarFrame3();
tf3.setVisible(true);

Anonymous    May 01, 2004
Printed
Page 39
Code fragment, PageFrame.java

The comment associated with this source code segment:

// PageFrame.java
// A simple extension of the JInternalFrame class that contains a list
// object. Elements of the list represent HTML pages for a web site.
//

NOW READS:
// PageFrame.java
// A simple extension of the JInternalFrame class that contains a textarea
// and a local menu to save changes to simple HTML text.

Anonymous    May 01, 2004
Printed
Page 43
1st line

Reference to Table 3-2 should be 3-1.

Anonymous    Mar 09, 2012
Printed
Page 43
Table 3-2

At the bottom of the table:
See also java.awt.ActionListener

NOW READS:
See also java.awt.event.ActionListener

Anonymous    May 01, 2004
Printed
Page 50
1st par., GuiScreens.java code listing

The following line:
frame[j][i].setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );

HAS BEEN ADDED just prior to the line in the existing code:

frame[j][i].setVisible(true);

Anonymous    May 01, 2004
Printed
Page 52
par. 3 - The ChangeListener Interface

This paragraph made reference to a com.sun.java.swing.event.ChangeListener
interface. This HAS BEEN CHANGED to javax.swing.event.ChangeListener.

Anonymous    May 01, 2004
Printed
Page 56
first two lines

JApplet HAS BEEN REMOVED from this particular list of top-level containers.

Anonymous    May 01, 2004
PDF
Page 65
1st paragraph

Rectangle r = new Rectangle( );
r = frame.getBounds(r);
System.out.println("X = " + r.x( ));
System.out.println("Y = " + r.y( ));
System.out.println("Width = " + r.width( ));
System.out.println("Height = " + r.height( ));

I found this topic 3.5.6 Position, Size, and Alignment talk about the propertys,and I read http://java.sun.com/javase/6/docs/api/java/awt/Rectangle.html.
The Rectangle class has the fields:
Field Summary
int height
The height of the Rectangle.
int width
The width of the Rectangle.
int x
The X coordinate of the upper-left corner of the Rectangle.
int y
The Y coordinate of the upper-left corner of the Rectangle.
so We need to change the code to :
Rectangle r = new Rectangle( );
r = frame.getBounds(r);
System.out.println("X = " + r.x);
System.out.println("Y = " + r.y);
System.out.println("Width = " + r.width);
System.out.println("Height = " + r.height);

Note from the Author or Editor:
This is correct. It looks like the author of this page couldn't decide whether to use the properties, or the public fields (yuck) in the Rectangle object. The code should be either as the reader shows (removal of the parentheses from the field accesses), or it should use getX(), getY(), getWidth() and getHeight(). I would vote for the latter.

Anonymous  Oct 23, 2008 
Printed
Page 74
code sample, center page

exampleButon.getActionMap().put("download",exampleAction);
exampleButton.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke("F8"),"download");

The first variable should be named "exampleButton" not "exampleButon"

Anonymous    Mar 09, 2012
Printed
Page 75
1st line

is:
public void setInputMap(int condition)

should be:
public void setInputMap(int condition, InputMap map)

Note from the Author or Editor:
The reader is correct; the line should be as they specified in their erratum. Thanks for catching that.

Bjarke Skjernaa  Mar 15, 2009  Mar 09, 2012
Printed
Page 81
3/4 of the way down the page

"public KeyStroke[] keys" should be "public KeyStroke[] keys()"

Anonymous    Mar 09, 2012
Printed
Page 166
Table 7-2

Table 7-2 lists the property elementAt as an indexed property with a bullet under the
"set" column. Although there is a setElementAt(Object obj, int index) method on
DefaultListModel, this is not the signature
of a setter for an indexed property and you cannot use reflection on
elementAt with an indexed write method. The bullet under the set column should be
removed for elementAt. It seems other tables correctly show this situation such as
Table 7-12, page 196, as an example.

AUTHOR: The reader is correct. The proper method signature would be
setElementAt(int, Object). The bullet should be removed, although
I would note in the errata that both of the following methods are
available for setting the value of a particular element:

public void setElementAt(Object elem, int index);
public void set(int index, Object elem);

We probably should have footnoted that fact...

Anonymous    Mar 09, 2012
Printed
Page 227
code example, middle of the page

the closing curly brace is indented a few spaces.
very minor formatting problem.
"...
getContentPane().add(notOpaque);
}"
Should be:
"...
getContentPane().add(notOpaque);
}"

Anonymous    Mar 09, 2012
Printed
Page 233
GlassExample.java

There is an updated version of the GlassExample available at -
http://examples.oreilly.com/9780596004088/code/ch08/newglass.zip
This fixes two bugs:
1) Key events were not supressed in the original example, they are now
2) On 1.2 and 1.3 systems, first mouse click after removing glass pane
would not be sent to the component under the mouse. This was a bug
in the way JRootPane handled the glass pane component that has been
fixed in the 1.4 release. FixedGlassPane.java (see below) provides
a workaround for 1.2 and 1.3, but is still safe to use with 1.4.

The updated files are:

GlassExample.java Updated to use (and control) the new glass pane
FixedGlassPane.java Extension of JPanel that allows for redispatching
erroneous events to their rightful owners


Anonymous   
Printed
Page 323
Table 11-3

The JScrollPane properties "columnHeader" and "rowHeader" has "set"-methods missing. Both properties should have a bullet in the "set" column.

Anonymous    Mar 09, 2012
Printed
Page 368
Figure 12-3;

Figure 12-3 : "JFileChooser in the Windows, Motif, and Mac L&F"

NOW READS:
"JFileChooser in the Metal, Motif and Mac look and feels"

Anonymous    May 01, 2004
Printed
Page 448
below Table 14-4

Below table 14-4 is a reference to the properties table of the AbstractButton class.
The reference below Table 14-4 NOW POINTS TO Table 5-5, not Table 5-4.

Anonymous    May 01, 2004
Printed
Page 465
IN PRINT"

public void 486addSeparator()

NOW READS:
public void addSeparator()

Anonymous    May 01, 2004
Printed
Page 491
Figure 15-2 JTable class diagram

In the upper right box (javax.swing.event), you state that JTable implements:
TableModelListener (1st occurence)
TableColumnModelListener,
TableModelListener (2nd occurence)
TableModelListener (3rd occurence)

According to the Java 1.4.2 API: the box (javax.swing.event) should state that JTable
implements:
TableModelListener
TableColumnModelListener
ListSelectionListener
CellEditorListener

Anonymous   
Printed
Page 512
2nd paragraph, 1st sentence

,,The TableModel interface has one other interface, shown here with its implementation:B4B4

NOW READS:
,,The AbstractTableModel class has one other useful method:B4B4

Anonymous    May 01, 2004
Printed
Page 583
1st paragraph

"The toggleClickCount property allows you to specify how many clicks
are required to start editing a tree node."

should read:

"The toggleClickCount property allows you to specify how many clicks
trigger an action on a tree node. If that node is a leaf and the tree
is editable, it will start the editing process. For non-leaf nodes
(folders), the appropriate number of clicks will expand or collapse the
node."

Anonymous    Mar 09, 2012
Printed
Page 792
13 lines from the bottom

styleBox.getStyleName().length() > 0) {

NOW READS:
styleBox.getStyleName() != null) {

Anonymous    May 01, 2004
Printed
Page 797
14th line in code

The word "swing2IX.fm" HAS BEEN DELETED and and the rest of the line HAS BEEN SHIFTED left to line
up with the one above it.

Anonymous    May 01, 2004
Printed
Page 924
1st paragraph (line 1)

"The component and ropTarget properties are both...."

should be:

"The component and dropTarget properties are both...."

Anonymous    Mar 09, 2012
Printed
Page 956
Comments for TreeDragSource.java

The comment for TreeDragSource.java includes the words "This is the Drop half."
They should read: "This is the Drag half."

Anonymous    Mar 09, 2012
Printed
Page 956
IN PRINT: right before code example

Text reads "Don't worry too much about the TransferableTreeNode class (we discuss
this in greater detail in the next section)."

The class is never described or defined in the "next section" or the rest or the
chapter (or in any other), and can only be found on the website.

AUTHOR: True. The code is online, but the discussion of
it is indeed missing from the book. An explanation should
be included in future reprints/editions of this book.

Anonymous    Mar 09, 2012
Printed
Page 1010
3rd paragraph

With J2SE SDK 1.4, the MacMetrics jar file contains classes that were
compiled in the default package. As such, they will only work with
your application if it, too, resides in the default package.
Regrettably, we have neither the source nor the permission to alter the
jar file. A simple launching application written as part of the
default package however, should be able to bootstrap larger
applications during development.

Anonymous   
Printed
Page 1076
in enumeration, key word "Tooltips"

Tooltips
The ToolTipManager and JToolTip classes

The name of the class is ToolTipManager with a capital T for Tip.

Anonymous    Mar 09, 2012
Printed
Page 1126
2nd paragraph

"...inside a container in whi'ch pop ups are used?"
should read:
"...inside a container in which pop ups are used?"

Anonymous    Mar 09, 2012