I need to draw a few hundred asterisks at random places and in random colors, then write my name over the top. I need to pass in my name to the applet as a PARAM from the html page. I think I know how to do this but I have no idea how to draw the random asterisks in random colors. ONce again any help would be much appreciated, everyone has been great so far.
Steve
12-04-2004, 10:25 AM
sirsteve
O.K, here is what I have so far:
import java.awt.*;
import java.applet.*;
public class NameInLights extends Applet
{
Font header= new Font("SanSerif",Font.BOLD,24);
String text;
public void init()
{
text= getParameter("message");
if(text==null)
text="nothing to say";
}
public void paint(Graphics g)
{
g.setFont(header);
for(int i=0;i<100;i++);
{
int x = (int)(Math.random() * 399);
int y = (int)(Math.random() * 399);
int red = (int)(Math.random() * 256); //random rgb values
int green = (int)(Math.random() * 256);
int blue = (int)(Math.random() * 256);
Color asterisk = new Color(red,green,blue);
g.setColor(asterisk);
g.drawString("*",x,y);
}
g.drawString(text, 100,100);
}
};
And here is my HTML code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>