Java Reference
In-Depth Information
8. Save the program again. Compile and execute it by performing these state-
ments in the command window:
javac -classpath c:\java4cobol HelloWorld.java
appletviewer -J-classpath -J.;c:/java4cobol HelloWorld.html
Your applet window should look like this:
Hello applet World!
Some Text
Some New Text
Some Text for #2
Some New Text
The appletviewer that comes with SDK does not print null as the way to represent
an uninitialized String ; instead, it generates an exception, or error condition.
Therefore, the ErrorMsg class (as defined for the exercises) initializes its data mem-
ber named msgText to a single space.
9. Now, have the applet use the overloaded version of getErrorMsg . Add the
following lines to the end of yourHelloWorld.java source file (i.e., imme-
diately after the last g.drawString statement):
// Call the new variation of the getErrorMsg method.
// This variation will return an all uppercase message.
tempMsg = myErrorMsg.getErrorMsg ('U');
g.drawString (tempMsg, 5, 95);
10. Save the program again. Compile and execute it by performing these state-
ments in the command window:
javac -classpath c:\java4cobol HelloWorld.java
appletviewer -J-classpath -J.;c:/java4cobol HelloWorld.html
Search WWH ::




Custom Search