|
Day 9: Making Programs Look Good with Graphics, Fonts, and Color
NOTES AND CORRECTIONS
- In Listing 9.1, Line 4 is missing a public modifier. The corrected
line is the following:
- public void paint(Graphics screen) {
- On Page 224 in the section on drawing arcs, it states that "the
number of degrees traveled by the arc is specified in a clockwise direction
by using positive numbers. This is the opposite of the way a non-2D arc is
handled." This is true of beta versions of JDK 1.2, but was corrected
for the final release. The number of degrees traveled is specified in a
counterclockwise direction.
- In Listing 9.5, Lines 15-16, if you're not using a beta version of JDK
1.2, one of the arguments should be changed from 180 to -180 so that the
arcs look like ocean waves and match Figure 9.17. The correct lines are the
following:
- Arc2D.Float wave = new Arc2D.Float(ax, ay,
10, 10, 0, -180, Arc2D.OPEN);
SOURCE FILES
READER QUESTIONS
- Q: The Map2D applet compiles and can be run within appletviewer,
but it won't run in either the current Netscape Navigator or Microsoft
Internet Explorer. Why is this the case when other applets will run? --K.O.
- A: Map2D won't run outside of appletviewer because it's one
of several applets in the book that requires a Java 1.2-capable browser.
Neither Navigator nor Internet Explorer supports 1.2 fully at this time, so
Sun has developed a Java
Plug-in that enhances their built-in Java support.
The Plug-in is a Java interpreter that can be used as an alternative to the
Java interpreters included with Navigator and Internet Explorer. A Java
programmer uses a modified <APPLET> tag to make the Java
Plug-in run the applet if the plug-in is present on a user's system (if not,
the plug-in can be immediately installed).
Sun has created an HTML
Converter that will read an .html file containing applets and
convert the HTML so that the applets use the Java Plug-in.
None of the book's .html files have been modified to call the Java
Plug-in, so they're being added to this Web site as time permits. The first
example is Map2D_plugin.html.
- Q: I'm using your book with JBuilder 2 Standard Edition. Why do I
get an error involving the java.awt.geom.* package when I try
to compile the Map2D applet?
- A: JBuilder 2 comes equipped with tools that support version 1.1 of
the Java language. Any program that uses a new feature of Java 1.2 -- in
this case, the whole java.awt.geom.* package is new -- will cause an
error. To fix this, you can install JDK 1.2 and configure JBuilder to use it
with the Tools | Project Properties... menu command.
An easier solution is to use JDK 1.2 when working through the days of this
book, because the examples were written specifically for the JDK. It will be
much easier to learn how to use JBuilder after you're comfortable with the
concepts of Java programming.
LINKS
|