applet parameters
i run the applet but all i get is a message saying that the applet has started but it doesnt run
import java.applet.*;
import java.awt.*;
/*
<applet code="AppletParameters" width = 300 height=300>
<param name="background" value="0xffffff">
<param name="foreground" value="0x000000">
<param name="message" value="Testing Applet
Parameters">
</applet>
*/
public class AppletParameters extends Applet {
public void paint(Graphics g) {
String background = getParameter("background");
String foreground = getParameter("foreground");
String message = getParameter("message");
setBackground(Color.decode(background));
setForeground(Color.decode(foreground));
Font font = getFont();
FontMetrics fm = getFontMetrics(font);
Dimension d = getSize();
int x = (d.width - fm.stringWidth(message))/2;
int y = d.height/2;
g.drawString(message, x, y);
}
}
|