设置一下前景颜色就行了咯。

解决方案 »

  1.   

    //我想让输出的点,每个点都是不同颜色可以吗??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);
                }
            }
        }
    }
      

  2.   

    那你就在每次画点之前,改变前景色