50 20 20 5 (20, 20) O 50 100 150 200 250 300 350 x (reserved 50 100 y
50 20 20 5 (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; (reserved public class Blocks1 extends JApplet { public void paint(graphics g){ g.drawrect( 20, 20, 50, 20); g.drawrect( 90, 20, 50, 20); g.drawrect(160, 20, 50, 20); g.drawrect(230, 20, 50, 20); g.drawrect(300, 20, 50, 20); 10 } }
50 10 10 10 (20, 20) (reserved
(variable) (type) 50 20 20 5 (reserved
Blocks2.java import javax.swing.japplet; import java.awt.graphics; public class Blocks2 extends JApplet { public void paint(graphics g){ int w = 50, h = 20, x = 20, y = 20, space = 20; g.drawrect(x, y, w, h); x = x + w + space; 10 g.drawrect(x, y, w, h); (reserved } } x = x + w + space; g.drawrect(x, y, w, h); x = x + w + space; g.drawrect(x, y, w, h); x = x + w + space; g.drawrect(x, y, w, h); 20
...... int() (e.g. -20, 10) float, double() (e.g. -1.23, 3.4) ; (e.g. int x;),,...; (e.g. int x, y, z;) () = ; (e.g. x = 3;, x = a + b;) (reserved
int() 1, 12, -50 float, double 1.23, -10.5 () char() a, x, Z boolean( ) true false (reserved
boolean true false byte 8bit short 16bit int 32bit ( 2 31 2 31 1) long 64bit ( 2 63 2 63 1) char 16bit Unicode float 32bit double 64bit (reserved
(declaration) ; int a;,,... ; double avg1, val x; (reserved
( ) camel case() = ; =... (assignment) (reserved
(reserved () abstract boolean break byte case catch char class const continue default do double else extends final finally float for goto if implements import instanceof int interface long native new package private protected public return short static super switch synchronized this throw throws transient try void volatile while (reserved
50 10 10 10 (20, 20) (reserved
gif a (10, 10) a (http://ushikai.com/index.htm) web (reserved
ImagePut.java (1)(ImagePut.java) import javax.swing.japplet; import javax.swing.imageicon; import java.awt.graphics; public class ImagePut extends JApplet { ImageIcon icon; (reserved public void init(){ icon = new ImageIcon(getImage(getCodeBase(), "den1s.gif")); } 10 } public void paint(graphics g) { icon.painticon(this, g, 10, 10); }
ImagePut.java 2 java.swing ImageIcon 6 ImageIcon icon ImagePut (reserved ()
ImagePut.java 9 getcodebase applet URL URL http://www.img.cs.titech.ac.jp/ rocky/imageput.html applet URL http://www.img.cs.titech.ac.jp/ rocky/ Image getimage(url url, String name) URL name ImageIcon(Image image) Image ImageIcon (reserved 12 painticon(component c, Graphics g, int x, int y) Component: applet (this) Graphics: (x, y):
ImagePut.java 8 init applet (reserved
gif (10, 10) (reserved
ImagePutBox.java (2)(ImagePutBox.java) import javax.swing.japplet; import javax.swing.imageicon; import java.awt.graphics; public class ImagePutBox extends JApplet { ImageIcon icon; int w, h; public void init(){ icon = new ImageIcon(getImage(getCodeBase(), "den1s.gif")); 10 w = icon.geticonwidth(); h = icon.geticonheight(); } (reserved } public void paint(graphics g) { icon.painticon(this, g, 10, 10); g.drawrect(10, 10, w, h); }
ImagePutBox.java 7 (w) (h) 11, 12 geticonwidth geticonheight icon (reserved
gif 5 (reserved