/* ----------------------------------------------------------------- 直線の模様1 Applet_drawLine_loop1 (実行方法) @コンパイルを行う ACpadのコマンド入力欄に次のコマンドを入れて「実行」をクリック appletviewer クラス名.java ------------------------------------------------------------------ */ import java.applet.*; import java.awt.*; /* */ public class Applet_drawLine_loop1 extends Applet { public void paint(Graphics g) { int x; // ------- 縦の平行線 ------- for ( x=100 ; x<=300 ; x+=10 ) { g.drawLine(x,100,x,300); } int y; // ------- 横の平行線 ------- g.setColor(Color.blue); for ( y=400 ; y<=600 ; y+=5 ){ g.drawLine(100,y,300,y); } // ------- 斜めの線 ------- for ( x=400 ; x<=800 ; x+=10 ){ g.drawLine(400,100,x,400); } g.setColor(Color.magenta); for ( x=800 ; x>=400 ; x-=10 ){ g.drawLine(800,100,x,400); } } }