/* works!
Topics:
1. Passing parameters to an applet.
2. init() method.
3. Inputting a string variable name.
*/
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
import corejava.*;
import java.text.*;
public class awttest extends java.applet.Applet
{ Font f = new Font("TimesRoman", Font.ITALIC,24);
String name; // creates variable 'name'
public void init()
{ name = Console.readString("Type your name, please.");
if (name == null)
name = "Go Baby!";
}
public void paint(Graphics g)
{ g.setColor(Color.blue);
g.setFont(f);
g.drawString ("Hello " + name, 5, 25);
}
}
/*
passes name from console to applet. good show!
the batch file below was created to expedite compiling, executing class
or running html with the applet viewer:
c.bat
ECHO OFF
rem created by j.auciello. takes out most problems calling
rem compilers, executers, etc. has fail-safe qualities.
echo .. DIRECTORY OF %1.j*
copy %1.jav *.java
dir %1.j*
pause
type %1.java
ERASE %1.class
javac %1.java
echo .. DOES %1.class EXIST?
dir %1.class
pause
java %1
av %1.htm
end of listing
*/