random时生成0到1的随机数。。你在前面乘以3就行了
import java.awt.*;import java.applet.*;import java.util.*;public class drawTest extends Applet { public void paint(Graphics g){ Random r = new Random();int i=r.nextInt(3)+1;switch(i){ case 1:{g.setColor(Color.green);for(int j=1;j<=10;j++)g.drawLine(j*4,20,j...