Errata

Java Swing

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

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

Version Location Description Submitted by Date submitted
Printed Page 37
5th line

There seems to be an extra closing bracket.

Anonymous   
Printed Page 38
In SiteFrame.java listing line 28 from the first comment line

In the SiteManager example code, there is a small error..

You add a ListSelectionListener to the nameList. In this function, you need to check whether the
selection is in progress or is finished. The way it is written causes the selected PageFrame to
be displayed twice.

To fix it, you need only add one conditional statement:

nameList.addListSelectionListener (new ListSelectionListener () {
public void valueChanged (ListSelectionEvent lse) {

// Add this conditional statement:
if (!lse.getValueIsAdjusting ()) {
parent.addPageFrame ((String)nameList.getSelectedValue ());
}// end if
} // end valueChanged ()
});

This will ensure that the page is only displayed once upon selection.

Anonymous   
Printed Page 65
Final paragraph

From the book:

"Swing currently provides several styles of borders, including an empty border. Each
one extends the javax.swing.border.Border interface."

The word "extends" should be "implements." Technically, it is the AbstractBorder
class that implements the Border interface, with the concrete border classes, such as
EmptyBorder, extending the AbstractBorder class.

Anonymous   
Printed Page 224
public IconSpinner class

The sample in the book tries to load sample icons 1.gif .. 6.gif, that are not
included with the downloadable samples. Editing the IconSpinner.java file, replace
these with something like

Icon nums[] = new Icon[] {
new ImageIcon("covers/ant.gif"),
new ImageIcon("covers/java2d.gif"),
new ImageIcon("covers/jdbc.gif"),
new ImageIcon("covers/jcook.gif"),
new ImageIcon("covers/jsoap.gif"),
new ImageIcon("covers/swing.gif")
};

Anonymous   
Printed Page 252
"public static void main" procedure

"non-static variable this cannot be referenced from a static context"

This is what happens when we compile.

Happens with this piece of code:

SplashScreen splash = new SplashScreen(10000);

Anonymous   
Printed Page 362
Table 11-17

While Table 11-17 suggests that the Spring class has the properties maximum, minimum and
preferred, it has in fact the properties maximumValue, minimumValue and preferredValue.

Anonymous   
Printed Page 377
2nd paragraph

While text states that the nodesWereRemoved() method has the signature

public void nodesWereRemoved(TreeNode node, int childIndices[])

the correct signature according to the Java API 1.5.0 is in fact

public void nodesWereRemoved(TreeNode node, int childIndices[], Object[] removedChildren)


Anonymous   
Printed Page 515
penultimate paragraph

Talking about firstRow and lastRow: "either property may be a specific column [...]". It should
read: "either property may be a specific row [...]"

Anonymous   
Printed Page 945
Last paragraph

Both Table 24-16 and the text suggest that cursor is a read-only property of the
DragSourceContext class. However, at least for Java 5 and 6 (I didn't check for earlier
versions), there does in fact exist a setCursor() method for setting it.

Anonymous   
Printed Page 948
Last paragraph / Table 24-18

In Java 5 and 6 (I didn't check for earlier versions), the DragSourceEvent class has also a
location property (and respective getLocation(), getX() and getY() methods), which is mentioned
neither in the text nor in Table 24-18.

Anonymous   
Printed Page 1153
code

I downloaded the files for Sketch from the website and tried running the program. I received the following error:

UIDefaults.getUI() failed: no ComponentUI class for: dial.JogShuttle[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=java.awt.Dimension[width=80,height=80],preferredSize=java.awt.Dimension[width=80,height=80]]
java.lang.Error
at javax.swing.UIDefaults.getUIError(UIDefaults.java:711)
at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:133)
at javax.swing.UIDefaults.getUI(UIDefaults.java:741)
at javax.swing.UIManager.getUI(UIManager.java:1016)
at dial.JogShuttle.updateUI(JogShuttle.java:51)
at dial.JogShuttle.init(JogShuttle.java:45)
at dial.JogShuttle.<init>(JogShuttle.java:37)
at dial.Sketch.<init>(Sketch.java:36)
at dial.Sketch.main(Sketch.java:85)

Anonymous  Dec 14, 2008 
Printed Page 1153
code

I downloaded the files for Sketch from the website and tried running the program. I received the following error:

UIDefaults.getUI() failed: no ComponentUI class for: dial.JogShuttle[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=java.awt.Dimension[width=80,height=80],preferredSize=java.awt.Dimension[width=80,height=80]]
java.lang.Error
at javax.swing.UIDefaults.getUIError(UIDefaults.java:711)
at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:133)
at javax.swing.UIDefaults.getUI(UIDefaults.java:741)
at javax.swing.UIManager.getUI(UIManager.java:1016)
at dial.JogShuttle.updateUI(JogShuttle.java:51)
at dial.JogShuttle.init(JogShuttle.java:45)
at dial.JogShuttle.<init>(JogShuttle.java:37)
at dial.Sketch.<init>(Sketch.java:36)
at dial.Sketch.main(Sketch.java:85)

Anonymous  Dec 14, 2008