Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lesson 10. 애플릿과 그래픽.

Similar presentations


Presentation on theme: "Lesson 10. 애플릿과 그래픽."— Presentation transcript:

1 Lesson 애플릿과 그래픽

2 애플릿이란?

3 CGI(Common Gateway Interface)

4 애플릿의 정의 import java.applet.Applet;  Applet 패키지 import Applet 클래스 상속
class 애플릿이름 extends Applet  애플릿 헤더 { // 멤버변수 선언 // 메소드 구현 } 애플릿 바디

5 CODE CODEBASE ARCHIVE NAME ALIGN HSPACE VSPACE WIDTH HEIGHT PARAM
HTML문서에서 인수 전달하기 <HTML> <BODY> <APPLET CODE=애플릿이름.class [ CODEBASE=애플릿위치 ARCHIVE=JAR파일이름 NAME=애플릿이름 ALIGN=정렬방식 HSPACE=수평공간크기 VSPACE=수직공간크기 ] WIDTH=가로크기 HEIGHT=세로크기> <PARAM NAME=속성이름 VALUE=속성값> </APPLET> </BODY> </HTML> CODE CODEBASE ARCHIVE NAME ALIGN HSPACE VSPACE WIDTH HEIGHT PARAM

6 애플릿 라이프 사이클 import java.applet.Applet;
public class MyApplet extends Applet { public void init() // 초기화 루틴 }

7 애플릿 컴파일과 실행 컴파일 실행 javac MyApplet.java  애플릿 프로그램
appletviewer MyApplet.html  애플릿이 연결된 HTML 문서

8 색상 지정 1 : import java.awt.*; 2 : import java.applet.*; 3 :
4 : public class ColorTest extends Applet 5 : { 6 : public void init() 7 : { 8 : setBackground(Color.yellow); 9 : } 10 : 11 : public void paint(Graphics g) 12 : { 13 : g.setColor(Color.blue); 14 : g.drawString("노란색 바탕에 파란색으로 글씨를 씁니다.", 20, 100); 15 : } 16 : }

9 글꼴 지정 Font myFont = new Font("SansSerif", Font.BOLD, 12);
글꼴이름 글꼴형태 글꼴크기    Font myFont = new Font("SansSerif", Font.BOLD, 12); g.setFont(myFont);   그래픽컨텍스트 Font형인수 Font.PLAIN Font.BOLD Font.ITALIC Font.BOLD+Font.ITALIC 자바 표준 글꼴 Serif SansSerif Monospaced

10 문자 출력 1 : import java.awt.*; 2 : import java.applet.*; 3 :
4 : public class StringTest extends Applet 5 : { 6 : char[] myChars= {'프', '로', '그', '래', '밍'}; 7 : byte[] myBytes= {0x4a, 0x41, 0x56, 0x41}; 8 : 9 : public void paint(Graphics g) 10 : { 11 : g.drawString("자바2", 10, 20); 12 : 13 : g.drawChars(myChars, 0, myChars.length, 10, 50); 14 : 15 : g.drawBytes(myBytes, 0, myBytes.length, 10, 80); 16 : } 17 : }

11 선 그리기 g.drawLine(100, 120, 400, 450);     x1 y1 x2 y2 (100, 120)
    x y x y2 (100, 120) (400,450)

12 사각형 그리기 사각형: drawRect(), fillRect()
둥근 사각형: drawRoundRect(), fillRoundRect() 3차원 사각형: draw3DRect(), fill3DRect() g.drawRect(200, 100, 80, 50);     x좌표 y좌표 폭 높이 g.drawRoundRect(200, 100, 80, 50, 60, 40);   모서리폭 모서리높이 (200,100) 80 50

13 타원 그리기 g.drawOval(200, 100, 80, 50); g.fillOval(200, 100, 80, 50);
    x좌표 y좌표 폭 높이 g.fillOval(200, 100, 80, 50); (200,100) 50 80

14 부채꼴 그리기 g.drawArc(50, 20, 200, 80, 20, 320);       x좌표 y좌표 폭 높이 시작각도 회전각도 g.fillArc(50, 120, 200, 80, 20, 320); 90 180 270 360

15 다각형 그리기 int[] x1= {20, 40, 80, 250, 200}; int[] y1= {100, 50, 10, 50, 90}; g.drawPolygon(x1, y1, );    x좌표배열 y좌표배열 점의수 int[] x2= {20, 40, 80, 250, 200}; int[] y2= {200, 150, 110, 150, 190}; g.fillPolygon(x2, y2, 5);

16 연결선 그리기 int[] x1= {20, 40, 80, 250, 200}; int[] y1= {100, 50, 10, 50, 90}; g.drawPolyline(x1, y1, );    x좌표배열 y좌표배열 점의수


Download ppt "Lesson 10. 애플릿과 그래픽."

Similar presentations


Ads by Google