以前写过的一个里面用到画线方法了 简单屏保的Applet
贴出来你看看:
/*<applet code="Screen.class",width=500 height=500>
</applet>*/
import java.awt.*;
import java.awt.event.*;
import java.awt.color.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import java.lang.*;
public class Screen extends JApplet implements Runnable{
int a,b,c,d,e,f,h,i;
//int const=10000;
public void init(){
resize(500,500);
Container cp=getContentPane();
}
public void run(){
try{
System.out.println("");
}
catch(Exception e){
}
}
public void paint(Graphics g){
//Thread t=new Thread()
for(i=0;i<1000;i++){
a=(int)(Math.random()*500);
b=(int)(Math.random()*500);
c=(int)(Math.random()*500);
d=(int)(Math.random()*500);
e=(int)(Math.random()*256);
f=(int)(Math.random()*256);
h=(int)(Math.random()*256);
g.setColor(new Color(e,f,h));
g.drawLine(a,b,c,d);
if (i<1000)
try
{Thread.sleep(10);}
catch(Exception e) {}}
//g.setColor(Color.blue);
if (i==1000){
i=0;
super.paint(g);
repaint();
}
}
}