/* -------------------------------------------------------------------- 直線の描画 Applet_drawLine_loop1 -------------------------------------------------------------------- */ import java.awt.*; import java.applet.*; /* */ public class Applet_drawLine_loop1 extends Applet { public void paint(Graphics g) { int x,y; // ----縦の平行線 for ( x=100 ; x<=300 ; x+=10 ) { g.drawLine(x,100,x,400); } // ----横の平行線 g.setColor(Color.blue); for ( y=500 ; y<=700 ; y+=5 ) { g.drawLine(100,y,300,y); } // ----斜め線 g.setColor(Color.blue); for(x=400 ; x<=800 ; x+=5) { g.drawLine(400,100,x,400); } // ----逆方向からの斜め線 g.setColor(Color.magenta); for(x=800 ; x>=400 ; x-=5) { g.drawLine(800,100,x,400); } } }