/* ------------------------------------------------------------------- 直線の描画(1) Applet_drawLine_loop1 (アプレットの実行方法) (1)コンパイルを行う ( Ctrl+F8 ) (2)Cpadのコマンド入力欄に次のコマンドを入れて「実行」をクリック 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=x+10 ) { g.drawLine(x,100,x,400); } int y; // ----------- 横の平行線 ------------ for ( y=500 ; y<=700 ; y=y+10 ) { g.drawLine(100,y,300,y); } // ----------- 斜めの模様 ------------ g.setColor(Color.blue); for ( x=400 ; x<=800 ; x+=10 ) { g.drawLine(400,100,x,400); } // ----------- 逆方向からの模様 ------------ g.setColor(Color.magenta); for ( x=800 ; x>=400 ; x=x-10 ) { g.drawLine(800,100,x,400); } } }