10-chap10-applet.ppt [호환 모드] -...

16
Dongwon Jeong, [email protected]r 1 / 16 √ 원리를 알면 IT가 맛있다 자바 프로그래밍 입문 Java Programming for Beginners ehanbit.net chapter 10. 애플릿

Upload: lyanh

Post on 13-Feb-2018

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

1 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK

√ 원리를 알면 IT가 맛있다자바 프로그래밍 입문

Java Programming for Beginners

한빛미디어㈜ - 1 - ehanbit.net한빛미디어㈜ - 1 - ehanbit.net

ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK

chapter 10.

애플릿

한빛미디어㈜ - 2 - ehanbit.net한빛미디어㈜ - 2 - ehanbit.net

Page 2: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

2 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK학습목표

애플릿 동작 환경

브라우저에서 애플릿이 동작하는 방법

Graphics 객체의 주요 메소드를 이용한 그림 그리기

폰트와 색상 사용법

한빛미디어㈜ - 3 - ehanbit.net한빛미디어㈜ - 3 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK웹 브라우저를 통한 애플릿 실행과정

애플릿웹브라우저에서 HTML태그를 통해서 동작하는 동적 프로그램웹브라우저에서 HTML태그를 통해서 동작하는 동적 프로그램

애플릿 실행과정애플릿 실행과정웹 브라우저 주소줄에 해당 웹 서버의 페이지 URL을 입력하면, 웹 브라우저는 해당 웹 서버에 접속한 후, 문서를 요청한다.

웹 서버는 Samle.html 문서를 읽어서 웹 브라우저에게 전송한다.

웹 브라우저는 HTML 문서를 분석하다가, <APPLET> 태그를 만나면다시 그 웹 서버에 해당 클래스 MyApplet class를 요청한다다시 그 웹 서버에 해당 클래스 MyApplet.class를 요청한다.

웹 서버는 MyApplet.class를 읽은 후,

다시 웹 브라우저에게 MyApplet.class를 전송하고,

웹 브라우저는 지정된 width와 height에 맞게 브라우저 화면을 할당하고, 자바 가상 머신을 통해 애플릿이 실행되도록 한다.

한빛미디어㈜ - 4 - ehanbit.net한빛미디어㈜ - 4 - ehanbit.net

Page 3: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

3 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK웹 브라우저를 통한 애플릿 실행과정

www.webserver.com

1

웹 서버웹 브라우저6

http://www.webserver.com/Sample.html

33

5

Sample.html

MyApplet.class

S l ht l

2Sample.html

4

<HTML>

<BODY>

MyApplet.class4

<APPLET code=MyApplet.class width=100 height=100></APPLET>

</BODY>

한빛미디어㈜ - 5 - ehanbit.net한빛미디어㈜ - 5 - ehanbit.net

</BODY></HTML>

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿 데모 프로그램 실행 예제

명령 프롬프트

> cd Animator> appletviewer example1.html

결과

한빛미디어㈜ - 6 - ehanbit.net한빛미디어㈜ - 6 - ehanbit.net

Page 4: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

4 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿과 HTML 문서: example1.html

<html><head>

<title>The Animator Applet (1 1) - example 1</title><title>The Animator Applet (1.1) example 1</title><!-- Changed by: Herb Jellinek, 18-Apr-1996 -->

</head><body>

<h1>The Animator Applet (1 1) - example 1</h1><h1>The Animator Applet (1.1) example 1</h1><applet code=Animator.class width=460 height=160>

<param name=imagesource value="images/Beans"><param name=backgroundcolor value="0xc0c0c0"><param name=endimage value=10><param name=endimage value=10>

<param name=soundsource value="audio"><param name=soundtrack value=spacemusic.au><param name=sounds value="1.au|2.au|3.au|4.au|5.au|6.au|7.au|8.au|9.au|0.au"><param name=pause value=200><param name=pause value=200>

alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet,for some reason."Your browser is completely ignoring the &lt;APPLET&gt; tag!

</applet></applet><hr><a href="Animator.java">The source.</a><hr>

</body>

한빛미디어㈜ - 7 - ehanbit.net한빛미디어㈜ - 7 - ehanbit.net

</body></html>

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿과 HTML 문서: Sample.html

애플릿 태그 형식

<applet code="MyApplet.class" width="100" height="200">

①code=“[애플릿코드]” ②width=”애플릿이 동작할 화면 폭”

③height=”애플릿이 동작할 화면 높이”

<html>

<title>애플릿</title>title 애플릿 /title

<body>

<applet code="MyApplet.class" width="200" height="100">

</applet>

</body>

한빛미디어㈜ - 8 - ehanbit.net한빛미디어㈜ - 8 - ehanbit.net

</html>

Page 5: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

5 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿과 HTML 문서:MyApplet.java

import java.applet.Applet;

i t j t ;import java.awt.*;

public class MyApplet extends Applet {

// 페이지가 화면에 보이고 그림을 그리는 이벤트가 발생할 때마다 자동 호출

public void paint(Graphics g)

{명령 프롬프트

{

// 바탕을 노란색으로 색칠

setBackground(Color.yellow);

명령 프롬프트

> appletviewer Sample.html

// 화면에 x,y 위치에 문자열을 출

g.drawString("애플릿 프로그래밍", 50, 60);

}

결과

}

한빛미디어㈜ - 9 - ehanbit.net한빛미디어㈜ - 9 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿과 HTML 문서: 익스플로러를 이용해서 확인하기

결과

더블클릭더블클릭

한빛미디어㈜ - 10 - ehanbit.net한빛미디어㈜ - 10 - ehanbit.net

Page 6: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

6 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿 동작 과정 관련 예제: EX10_00.java

import java.awt.*;

public class EX10_00 {

// 페이지가 화면에 보이고 그림을 그리는 이벤트가 발생할 때마다 자동 호출

public void paint(Graphics g)

{

// 바탕을 노란색으로 색칠

k d(C l ll )Applet 클래스를 상속받지 않아

setBackground(Color.yellow);

// 화면에 x,y 위치에 문자열을 출

g.drawString("애플릿 프로그래밍", 50, 60);

해당 메소드를 실행할 수 없음. 따라서 오류 발생

g.drawString( 애플릿 프로그래밍 , 50, 60);

}

}

한빛미디어㈜ - 11 - ehanbit.net한빛미디어㈜ - 11 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿 동작 과정 관련 예제: EX10_01.java

import java.awt.*;

public class EX10_01 extends MyApplet { MyApplet 클래스는 Applet 클래스를 상속한 하위 클래스

public void paint(Graphics g)

{

따라서 EX10_01 객체도 Applet 객체로 형변환 가능

{

// Graphics 객체 g의 색상을 빨간색으로 변경한다.

g.setColor(Color.red);

// 상위 객체인 MyApplet 객체의 paint() 메소드를 호출한다.

super.paint(g);

}}

}

한빛미디어㈜ - 12 - ehanbit.net한빛미디어㈜ - 12 - ehanbit.net

Page 7: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

7 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿 동작 과정 관련 예제: EX10_01.html

<html>

<title>애플릿</title><title>애플릿</title>

<body>

<applet code="EX10_01.class" width="200" height="100">

</applet>

</body>

</html>

명령 프롬프트 결과

> appletviewer EX10_01.html

한빛미디어㈜ - 13 - ehanbit.net한빛미디어㈜ - 13 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK자바 애플리케이션과 자바 애플릿 비교

항목 자바 애플리케이션 자바 애플릿

GUI 선택 기본적으로 사용

메모리 요구량 JVM 기본 브라우저 사용량 + JVM 사용량메모리 요구량 JVM 기본 브라우저 사용량 JVM 사용량

배포 파일, HTTP 프로토콜 HTTP 프로토콜

초기 인자값 명령행 인자 <PARAM> 태그초기 인자값 명령행 인자 <PARAM> 태그

시작 메소드 public static void main(String[] args)

init(), start()main(String[] args)

용도 모든 자바 실행 환경 웹 브라우저를 통한 공통 접근 모듈, 웹 에니메이션, 원격 교육, 전자상거래자상거래

자동 업데이트 프로그래머가 구현해야 함 웹 서버를 통한 업데이트로 모든클라이언트 대응 가능

한빛미디어㈜ - 14 - ehanbit.net한빛미디어㈜ - 14 - ehanbit.net

Page 8: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

8 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿 상속 구조

Object

Componet

Containter

Panel

AppletApplet

MyApplet

EX10_01

한빛미디어㈜ - 15 - ehanbit.net한빛미디어㈜ - 15 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOKGraphics 객체의 주요 메소드 1

메소드 모양 형식

drawArc public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle);

drawOval public void drawOval(int x, int y, int width, int height)

drawPolygon public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)

d bli id d (i i i id h i h i h )drawRect public void drawRect(int x, int y, int width, int height)

drawRoundRect public void drawRoundRect(int x, int y, int width, int height int arcWidth int arcHeight)height, int arcWidth, int arcHeight)

draw3DRect public void draw3DRect(int x, int y, int width, int height, boolean raised)

fillArc public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle);

fillOval public void fillOval(int x int y int width int height)

한빛미디어㈜ - 16 - ehanbit.net한빛미디어㈜ - 16 - ehanbit.net

fillOval public void fillOval(int x, int y, int width, int height)

Page 9: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

9 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOKGraphics 객체의 주요 메소드 2

메소드 모양 형식

fillPolygon public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)

fillRect public void fillRect(int x, int y, int width, int height)

fillRoundRect public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)

fill3DRect public void fill3DRect(int x int y int width int heightfill3DRect public void fill3DRect(int x, int y, int width, int height, boolean raised)

drawLine public void drawLine(int x1, int y1, int x2, int y2);

drawPloyline public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)

drawString “ 애플릿 예제” public void drawstring(String str, int x, int y);

d I bli id d I (I i i t i t C l

한빛미디어㈜ - 17 - ehanbit.net한빛미디어㈜ - 17 - ehanbit.net

drawImage public void drawImage(Image img, int x, int y , Color color, ImageObserver imgobsr);

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK페이지 이동과 애플릿 동작

현재 페이지뒤로 앞으로

1

2 3애플릿

첫째 페이지 둘째 페이지 셋째 페이지

한빛미디어㈜ - 18 - ehanbit.net한빛미디어㈜ - 18 - ehanbit.net

Page 10: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

10 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿 생명주기와 관련 메소드

메소드 호출되는 시점

init() 맨 처음 애플릿 태그를 만나 애플릿이 로딩된 뒤에 호

start() HTML 페이지가 활성화될 때 마다 호출

stop() 활성화된 상태에서 다른 페이지로 이동할 때 마다 호출

destroy() 브라우저가 종료할 경우 호출

한빛미디어㈜ - 19 - ehanbit.net한빛미디어㈜ - 19 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿 생명주기 관련 예제: EX10_02.java

import java.awt.*;import java.applet.*;

public class EX10_02 extends Applet {

String str = "Applet;";public void paint(Graphics g) // 화면의 중앙을 구한다.{

int x = getWidth() - g getFontMetrics() stringWidth(str);int x = getWidth() g.getFontMetrics().stringWidth(str);if (x < 0)

x = 0;g.drawString(str, x / 2, getHeight()/2);

}

public void init() // 첫 <applet> 태그를 만나서 code 속성에 의해서 로딩을 한 경우에 호출public void init() // 첫 <applet> 태그를 만나서 code 속성에 의해서 로딩을 한 경우에 호출{

str = str + "init();";

}public void start() // <applet> 태그가 있고 code 속성에 의해서 지정된 페이지를 방문할 경우{{

str = str + "start();";

}public void stop() // 해당 html 페이지를 빠져나올 경우{

t t " t () "str = str + "stop();";}public void destroy() // 브라우저가 종료할 경우

{str = str + "destroy();";

한빛미디어㈜ - 20 - ehanbit.net한빛미디어㈜ - 20 - ehanbit.net

}}

Page 11: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

11 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿 생명주기 관련 예제: EX10_02.html

<html>

<title>애플릿</title><title>애플릿</title>

<body>

<applet code="EX10_02.class" width="200" height="100">

</applet>

</body>

</html>

결과명령 프롬프트

> appletviewer EX10_02.html

한빛미디어㈜ - 21 - ehanbit.net한빛미디어㈜ - 21 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿에 인자값 전달

HTML 문서에서 애플릿에 인자값 전달<PARAM> 태그 이용name과 value 속성 이용: 애플릿으로 해당 정보 전달getParameter() 메소드 이용: name을 String 객체 인자값getParameter() 메소드 이용: name을 String 객체 인자값으로 넘겨주면 리턴값으로 value에 해당하는 문자열을String 객체로 얻을 수 있다.String 객체로 얻을 수 있다.

한빛미디어㈜ - 22 - ehanbit.net한빛미디어㈜ - 22 - ehanbit.net

Page 12: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

12 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿에 인자값 전달 관련 예제: EX10_03.java

import java.applet.Applet;

import java.awt.*;

public class EX10_03 extends Applet {p _ pp {

String str = "Applet;";

public void paint(Graphics g)

{{

// <param name="arg1" value="test">에서 "test" 문자열을 구한다.

str = "arg1=" + getParameter("arg1");

int x = getWidth() - g.getFontMetrics().stringWidth(str);

if (x < 0)

x = 0;

g.drawString(str, x / 2, getHeight()/2);

}

}

한빛미디어㈜ - 23 - ehanbit.net한빛미디어㈜ - 23 - ehanbit.net

}

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿에 인자값 전달 관련 예제: EX10_03.html

<html>

<titl >애플릿</titl ><title>애플릿</title>

<body>

<applet code="EX10_03.class" width="200" height="100">

<param name="arg1" value="test">

</applet>

</body>/body

</html>

결과명령 프롬프트

> appletviewer EX10_03.html

한빛미디어㈜ - 24 - ehanbit.net한빛미디어㈜ - 24 - ehanbit.net

Page 13: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

13 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿과 보안

자바 애플릿 제한 사항(보안을 위해)다른 프로그램을 실행시키지 못한다.

지역 파일의 입출력이 불가능하다.

어떠한 네이티브 메소드도 호출하지 못한다.

내려받은 서버 이외의 어떠한 서버에도 네트워크 통신이불가능하다.

한빛미디어㈜ - 25 - ehanbit.net한빛미디어㈜ - 25 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK애플릿이 특정 실행 파일을 실행시키는 예제: E10_04.java

import java.applet.Applet;

public class EX10_04 extends Applet {public void start(){

()Runtime runtime = Runtime.getRuntime();try {

runtime exec("notepad exe");runtime.exec( notepad.exe );} catch (Exception e){

e.printStackTrace();}}

}}

예외 사항 발생명령 프롬프트

> appletviewer EX10 04.html

결과

한빛미디어㈜ - 26 - ehanbit.net한빛미디어㈜ - 26 - ehanbit.net

> appletviewer EX10_04.html

Page 14: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

14 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK색상과 폰트

Color 객체그래픽 컴포넌트가 사용하는 속성

Java.awt 패키지에서 제공

Color.red(빨강), Color.green(초록), Color.blue(파랑) 인자값 3개를 이용해서 색상 표현

기본값은 Color.black

한빛미디어㈜ - 27 - ehanbit.net한빛미디어㈜ - 27 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOKColor 객체 관련 예제: EX10_05.java

public class EX10_05 extends Applet {Button b1 = new Button("버튼");Button b1 new Button( 버튼 );Label l1 = new Label("텍스트");TextField t1 = new TextField(20);Font f1 = new Font("굴림",Font.ITALIC,12);Font f2 = new Font("돋움",Font.ITALIC+ Font.BOLD,12);Font f3 = new Font("바탕" Font BOLD 15);Font f3 = new Font( 바탕 , Font.BOLD, 15);public void init(){

add(b1);add(l1);dd(t1)

t1.setForeground(Color.blue);t1.setBackground(Color.yellow);t1 setFont(f3);add(t1);

t1.setText("입력하세요");l1.setBackground(Color.black);l1.setForeground(Color.magenta);l1.setFont(f1);

t1.setFont(f3);} public void paint(Graphics g){

int h = getHeight();int x getWidth();

( )b1.setForeground(Color.blue);b1.setBackground(Color.green);b1.setFont(f2);

int x = getWidth();for (int i = 1; i <= h; i++) {

g.setColor(new Color((float)i/h, (float)i/h, (float)i/h));g.drawLine(0,i,x,i);

}}}

}

한빛미디어㈜ - 28 - ehanbit.net한빛미디어㈜ - 28 - ehanbit.net

Page 15: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

15 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK자바, 윈도우, X윈도우, 매틴토시 폰트

자바 폰트 윈도우 폰트 X 윈도우 폰트 매킨토시 폰트

Monospaced Courier Adobe-courier Courier

Dialog Ms Sans Serif b&h-lucida Geneva

DialogInput Ms Sans Serif b&h-lucidatype-writer Geneva

SansSerif/Helvetica Arial Abode-Helvetica HelveticaSansSerif/Helvetica Arial Abode Helvetica Helvetica

Symbol WinDings itc-zapfdingbats Symbol

S if/Ti R Ti N R Ad b ti Ti RSerif/TimesRoman Times New Roman Adobe-times Times Roman

한빛미디어㈜ - 29 - ehanbit.net한빛미디어㈜ - 29 - ehanbit.net

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK화면에서 사용할 수 있는 폰트 출력예제: FontList.java

import java.awt.*;public class FontList {public class FontList {

public static void main(String[] args) {GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

S i [] f A il bl il N ()String[] fnames = ge.getAvailableFontFamilyNames();for(int i = 0; i < fnames.length; i++)

System.out.println(i + ":" + fnames[i]);}}

}

결과0:Agency FB1:Arial2:Arial Black3:Arial Narrow4:Arial Rounded MT Bold5:Arial Unicode MS

한빛미디어㈜ - 30 - ehanbit.net한빛미디어㈜ - 30 - ehanbit.net

Page 16: 10-chap10-Applet.ppt [호환 모드] - djeong.kunsan.ac.krdjeong.kunsan.ac.kr/.../10-chap10-Applet.pdf · Dongwon Jeong, djeong@kunsan.ac.kr 3 / 16 IT COOKBOOK 웹브라우저를통한애플릿실행과정

Dongwon Jeong, [email protected]

16 / 16

IT COOKBOOKIT COOKBOOKIT COOKBOOKIT COOKBOOK

Thank youThank you

한빛미디어㈜ - 31 - ehanbit.net한빛미디어㈜ - 31 - ehanbit.netehanbit.net