/* @file: Hello.java * @purpose: Use of parameters in Applets * This variation of the Hello World example * allows you to display different messages * via applet parameters. * @class: Visualization, Spring 2003 * @author: Chee Yap */ import java.applet.Applet; import java.awt.*; public class Hello extends Applet { public String greeting, who, color; public int fontsize; public void init() { setForeground(Color.white); setBackground(Color.black); greeting = getParameter("greeting"); who = getParameter("who"); color = getParameter("color"); fontsize = Integer.parseInt(getParameter("fontsize")); setFont(new Font("SansSerif", Font.BOLD, fontsize)); } public void paint(Graphics g) { if (greeting != null) { Dimension d = getSize(); if (color.equals("yellow")) setBackground(Color.yellow); else setBackground(Color.black); g.drawString(greeting + " " + who + "!", 10, (d.height/2)); } } }