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