Better Message Applet
// this applet gets two messages and font info from the html file and displays
// the messages on a yellow background in blue letters using the given font
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
import java.awt.Dimension;
public class BetterMsgApplet extends Applet
{
String theMessage;
String secondMessage;
int size;
String fontName;
Font theFont;
// get info from the html file, set up the messages, font and background color
public void init()
{
theMessage = getParameter("message");
secondMessage = getParameter("another");
size = Integer.parseInt(getParameter("textsize"));
fontName = getParameter("font");
theFont = new Font(fontName,Font.BOLD, size);
this.setBackground(Color.yellow);
}
// set the color for the words and display the applet
public void paint(Graphics g)
{
g.setFont(theFont);
g.setColor(Color.blue);
g.drawString(theMessage,50,100);
g.drawString(secondMessage, 50,200);
}
}