一个APPLET求救 设置一下前景颜色就行了咯。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //我想让输出的点,每个点都是不同颜色可以吗??import java.applet.*;import java.util.*;import java.awt.*;public class RandomPoint extends Applet implements Runnable{ private static Color[] colors = { Color.white,Color.black,Color.blue,Color.red, Color.yellow,Color.orange,Color.cyan,Color.pink, Color.magenta,Color.green }; Random random; float f; Thread thread; Graphics g; public void init() { random = new Random(); Thread thread = new Thread(this); g = getGraphics(); thread.start(); } public void run() { while(true) { //生成随机坐标 int x = (int)(Math.random() * 100); int y = (int)(Math.random() * 100); g.setColor(colors[(int)(Math.random() * 10)]); //在APPLET上画点! g.fillOval(x,y,5,5); try { thread.sleep(50); } catch(Exception e) { System.out.println(e); System.exit(0); } } }} 那你就在每次画点之前,改变前景色 递归调用程序 关于&与&&的详细区分? 关于main中FileInputStream的引用的赋初值问题 JAVA问题. "Hello".getBytes("UTF-16")=? 高手请进??? 求助, 写日志文件时碰到的难题!(在线等...) 急问:如何判断给定的pathname中路径名是否存在?即如何判断文件夹是否存在呢? 使用applet(Jcreator)怎么能够产生文件打开和保存对话框? 玩Robcode的请进 JNI能不能通过函数参数表传递基本类型的变量到JAVA里面 请问大家JAVA SERVER端安全如何保障?
import java.util.*;
import java.awt.*;public class RandomPoint extends Applet implements Runnable
{
private static Color[] colors =
{
Color.white,Color.black,Color.blue,Color.red,
Color.yellow,Color.orange,Color.cyan,Color.pink,
Color.magenta,Color.green
};
Random random;
float f;
Thread thread;
Graphics g;
public void init()
{
random = new Random(); Thread thread = new Thread(this);
g = getGraphics();
thread.start();
} public void run()
{
while(true)
{
//生成随机坐标
int x = (int)(Math.random() * 100);
int y = (int)(Math.random() * 100);
g.setColor(colors[(int)(Math.random() * 10)]);
//在APPLET上画点!
g.fillOval(x,y,5,5);
try
{
thread.sleep(50);
}
catch(Exception e)
{
System.out.println(e);
System.exit(0);
}
}
}
}