Errata

Mac OS X for Java Geeks

Errata for Mac OS X for Java Geeks

Submit your own errata for this product.

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 45
middle

Either the import section for SimpleEdit class needs java.awt.Toolkit or, on page 53,
private int preferredMetaKey = Toolkit.getDefaultToolkit()... needs the full
java.awt.Toolkit.getDefaultToolkit()... (as you have done in initComponents())
Very minor point: getLabel (page 54) and setLabel (page 53) are deprecated in 1.4.1.
They have been replaced by getText and setText.

Anonymous   
Printed Page 47
middle

Using javac compiler 1.6.0_65 with
MacOSX Yosemite Version 10.10.5 (14F2511)

I can not get the supplied copy of
https://resources.oreilly.com/examples/9780596004002/blob/master/macxjvgks_src_v1/SimpleEdit.app/Contents/MacOS/SimpleEdit

to build a method without errors:

Ready;16:01:21;~/Documents/Java Training:javac SimpleEdit.java
SimpleEdit.java:117: cannot find symbol
symbol : class SimpleEditPlugin
location: class com.wiverson.macosbook.SimpleEdit
SimpleEditPlugin myPlugin =
(SimpleEditPlugin)myClass.getConstructor(null).newInstance(null);
^
SimpleEdit.java:117: cannot find symbol
symbol : class SimpleEditPlugin
location: class com.wiverson.macosbook.SimpleEdit
SimpleEditPlugin myPlugin =
(SimpleEditPlugin)myClass.getConstructor(null).newInstance(null);
^
SimpleEdit.java:117: warning: non-varargs call of varargs method with
inexact argument type for last parameter;
cast to java.lang.Class for a varargs call
cast to java.lang.Class[] for a non-varargs call and to suppress this
warning
SimpleEditPlugin myPlugin =
(SimpleEditPlugin)myClass.getConstructor(null).newInstance(null);

^
SimpleEdit.java:117: warning: non-varargs call of varargs method with
inexact argument type for last parameter;
cast to java.lang.Object for a varargs call
cast to java.lang.Object[] for a non-varargs call and to suppress this
warning
SimpleEditPlugin myPlugin =
(SimpleEditPlugin)myClass.getConstructor(null).newInstance(null);

^
SimpleEdit.java:234: cannot find symbol
symbol : class SimpleEditPlugin
location: class com.wiverson.macosbook.SimpleEdit
SimpleEditPlugin currentPlugin;
^
SimpleEdit.java:237: cannot find symbol
symbol : class SimpleEditPlugin
location: class com.wiverson.macosbook.SimpleEdit
currentPlugin = (SimpleEditPlugin)e.nextElement();
^
SimpleEdit.java:307: cannot find symbol
symbol : class SimpleEditPlugin
location: class com.wiverson.macosbook.SimpleEdit
SimpleEditPlugin myPlugin = null;
^
SimpleEdit.java:311: cannot find symbol
symbol : class SimpleEditPlugin
location: class com.wiverson.macosbook.SimpleEdit
myPlugin =
(SimpleEditPlugin)(((JComponent)evt.getSource()).getClientProperty("plugin"));
^
SimpleEdit.java:416: cannot find symbol
symbol : class SimpleEditPlugin
location: class com.wiverson.macosbook.SimpleEdit
SimpleEditPlugin currentPlugin;
^
SimpleEdit.java:419: cannot find symbol
symbol : class SimpleEditPlugin
location: class com.wiverson.macosbook.SimpleEdit
currentPlugin = (SimpleEditPlugin)e.nextElement();
^
Note: SimpleEdit.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: SimpleEdit.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
8 errors
2 warnings

[ The -Xlint deprecation errors are]:
SimpleEdit.java:350: warning: [deprecation] setLabel(java.lang.String)
in javax.swing.AbstractButton has been deprecated
currentMenuItem.setLabel((String)menuconfig[i][0]);
^
SimpleEdit.java:366: warning: [unchecked] unchecked call to put(K,V) as
a member of the raw type java.util.Hashtable
menuItemsHashtable.put((String)menuconfig[i][0],
currentMenuItem);
^
SimpleEdit.java:384: warning: [deprecation] getLabel() in
javax.swing.AbstractButton has been deprecated
String input = ((JMenuItem)src).getLabel();
^
SimpleEdit.java:389: warning: [deprecation] getLabel() in
javax.swing.AbstractButton has been deprecated
String input = ((JButton)src).getLabel();

**** and ***

SimpleEdit.java:467: warning: [deprecation] hide() in java.awt.Window
has been deprecated
public void hide()
^
SimpleEdit.java:469: warning: [deprecation] hide() in java.awt.Window
has been deprecated
super.hide();
^
SimpleEdit.java:483: warning: [deprecation] show() in java.awt.Window
has been deprecated
public void show()
^
SimpleEdit.java:485: warning: [deprecation] show() in java.awt.Window
has been deprecated
super.show();
^
SimpleEdit.java:15: warning: [serial] serializable class
com.wiverson.macosbook.SimpleEdit has no definition of serialVersionUID
public class SimpleEdit extends javax.swing.JFrame

//////////////////////////////////////////////////////
Does the author have suggestions on how the source should be modified?

Richard Steele  May 23, 2020 
Printed Page 101
Underneath Figure 7.1

I needed to insert a "space" character immediately after the ":" in the mainfest file
example to make it work, i.e it needed to be:

"Main-Class: com/wiverson/macosbook/SimpleEdit"

Without the space inserted I got the following jar command error:

java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:359)
at java.util.jar.Manifest.read(Manifest.java:162)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:124)
at sun.tools.jar.Main.main(Main.java:904)

Anonymous