applet HTML BODY APPLET code Calculator class width




<applet> 태그 사용 <HTML> <BODY> <APPLET code = "Calculator. class" width = "200" height = "210"> </APPLET> </BODY> </HTML> 4



예제 Hello. World. java import java. applet. Applet; import java. awt. Graphics; public class Hello. World extends Applet { public void paint(Graphics g) { g. draw. String("Hello World~~", 20); } } applettest. html <HTML> <BODY> <APPLET CODE="Hello. World. class" WIDTH=100 HEIGHT=80> </APPLET> </BODY> </HTML> 7

<HTML><BODY> <APPLET CODE="Hello. World. class" WIDTH=100 HEIGHT=80> </APPLET> </BODY></HTML> 시작점 HEIGHT WIDTH=100 HEIGHT=80 WIDTH=150 HEIGHT=40 8



import java. applet. Applet; import java. awt. Graphics; public class Applet. Exam extends Applet { String temp = ""; public void init() { temp += "init()수행 "; } public void start() { temp += "start()수행 "; } public void stop() { temp += "stop()수행 "; } public void destroy() { <html> <body> <applet code="Applet. Exam" width=600 height=100> </applet> </body> </html> System. out. println("애플릿 종료"); } public void paint(Graphics g) { g. draw. String("애플릿 생명주기", 30); g. draw. String(temp, 10, 50); } } 11


<APPLET> 태그 예제 <html> <body> <applet code="Appletex" width=400 height=200> <param name=s. Name value=“Sans. Serif”> <param name=p. Name value=“Hello World”> </applet> </body> </html> 13

import java. awt. *; import java. applet. *; public class Appletex extends Applet { String style. Name, print. Name, error; public void start() { style. Name = get. Parameter("s. Name"); print. Name = get. Parameter("p. Name"); } public void paint(Graphics g) { Font font. Name = new Font(style. Name, Font. BOLD, 20); g. set. Font(font. Name); g. draw. String(print. Name, 100); } } 14

import java. applet. *; import java. awt. *; public class Image. Exam extends Applet { Image image; public void init() { image = get. Image(get. Document. Base(), "image. jpg"); } public void paint(Graphics g) { g. draw. Image(image, 0, 0, this); } } <html><body> <applet code="Image. Exam" width=250 height=210> </applet> </body></html> 15

16

17

- Slides: 18