10-Java Applet

Similar documents
Chap12

자바로

<4D F736F F F696E74202D20C1A63236C0E520BED6C7C3B8B428B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

MasoJava4_Dongbin.PDF

(Microsoft PowerPoint - ETRSRHFRXNAM.ppt [\310\243\310\257 \270\360\265\345])

02 C h a p t e r Java

Microsoft PowerPoint - 04-UDP Programming.ppt

01-OOPConcepts(2).PDF

JMF3_심빈구.PDF

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

제10장 자바 GUI 프로그래밍 IV

웹연동 } 웹 (Web) 환경에서데이터베이스시스템을연동하는방법은다음과같다 } Server Client 구조의통신 (2-Tier) } Server Middleware Client 구조의통신 (3-Tier) 2

09-interface.key

rmi_박준용_final.PDF

11장.key

제8장 자바 GUI 프로그래밍 II

9장.key

자바-11장N'1-502

PowerPoint Presentation

Microsoft PowerPoint - ÀÚ¹Ù08Àå-1.ppt

자바GUI실전프로그래밍2_장대원.PDF

05-class.key

Network Programming

Java ~ Java program: main() class class» public static void main(string args[])» First.java (main class ) /* The first simple program */ public class

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

12-file.key

03-JAVA Syntax(2).PDF

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

JMF2_심빈구.PDF

PowerPoint Presentation

ch09

Interstage5 SOAP서비스 설정 가이드

PowerPoint 프레젠테이션

10장.key

Microsoft PowerPoint - 14주차 강의자료

Java

Modern Javascript

14-Servlet

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras

Ext JS À¥¾ÖÇø®ÄÉÀ̼ǰ³¹ß-³¹Àå.PDF

JavaGeneralProgramming.PDF

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

신림프로그래머_클린코드.key

비긴쿡-자바 00앞부속

gnu-lee-oop-kor-lec10-1-chap10

Secure Programming Lecture1 : Introduction

I T C o t e n s P r o v i d e r h t t p : / / w w w. h a n b i t b o o k. c o. k r

歯NetworkKawuiBawuiBo.PDF

1

Spring Boot/JDBC JdbcTemplate/CRUD 예제

03장.스택.key

5장.key

초보자를 위한 자바 2 21일 완성 - 최신개정판

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

04장

FileMaker ODBC and JDBC Guide

Dialog Box 실행파일을 Web에 포함시키는 방법

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

PowerPoint Presentation

untitled

자바 프로그래밍

PowerPoint 프레젠테이션

iii. Design Tab 을 Click 하여 WindowBuilder 가자동으로생성한 GUI 프로그래밍환경을확인한다.

FileMaker ODBC and JDBC Guide

<4D F736F F F696E74202D20C1A63230C0E520BDBAC0AE20C4C4C6F7B3CDC6AE203128B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

MPLAB C18 C

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드]

11 템플릿적용 - Java Program Performance Tuning (김명호기술이사)

3ÆÄÆ®-11

교육2 ? 그림

( )부록

hd1300_k_v1r2_Final_.PDF

PowerPoint 프레젠테이션

쉽게 풀어쓴 C 프로그래밊

Javascript.pages

Microsoft PowerPoint - Java7.pptx

DocsPin_Korean.pages

PowerPoint Presentation

Java Programing Environment

07 자바의 다양한 클래스.key

6강.hwp

13ÀåÃß°¡ºÐ

Microsoft PowerPoint - JavaPrimer.ppt [호환 모드]

03장

Microsoft PowerPoint - Java-03.pptx

Microsoft PowerPoint - 03-TCP Programming.ppt

Microsoft PowerPoint - 12장

Microsoft PowerPoint - 06-Chapter09-Event.ppt

자바네트워킹1.PDF

파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

Microsoft PowerPoint - RMI.ppt

public class FlowLayoutPractice extends JFrame { public FlowLayoutPractice() { super("flowlayout Practice"); this. Container contentpane = getcontentp

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

교육자료

rosaec_workshop_talk

Contents. 1. PMD ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 2. Metrics ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 3. FindBugs ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 4. ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ

Transcription:

JAVA Programming Language JAVA Applet Java Applet >APPLET< >PARAM< HTML JAR 2

JAVA APPLET HTML HTML <APPLET> main( ). public Applet 3 (HelloWorld.html) <HTML> <HEAD> <!-- Generated by Kawa IDE --> <TITLE>Applet title</title> </HEAD> <BODY> <H1>First Heading</H1> <APPLET CODE=HelloWorld WIDTH=220 HEIGHT=150></APPLET> </BODY> </HTML> 4

(HelloWorld.java) import java.awt.graphics; import java.applet.applet; public class HelloWorldextends Applet { public void paint(graphics g) { g.drawstring("helloworld!!", 70, 30); C:\>javac HelloWorld.java C:\>appletviewer HelloWorld.html C:\> 5 6

(1) public void init( ); public void start( ); public void stop( ); public void destory( ); public void paint(graphics g); 7 (1) 8

(2) (AppletMethodTest.html) <HTML> <HEAD> <!-- Generated by Kawa IDE --> <TITLE>Applet title</title> </HEAD> <BODY> <H1>First Heading</H1> <APPLET CODE=AppletMethodTest WIDTH=150 HEIGHT=150></APPLET> </BODY> </HTML> 9 (3) (AppletMethodTest.java) import java.awt.*; import java.applet.applet; publicclass AppletMethodTest extends Applet { TextArea ta; int count; public AppletMethodTest() { ta = newtextarea(4, 20); add(ta); count=0; public voidinit() { ta.append("init"+(count)+"\n"); System.out.println("init"+(count++)); public voidstart() { ta.append("start"+(count)+"\n"); System.out.println("start"+(count++)); publicvoidstop() { ta.append("stop"+(count)+"\n"); System.out.println("stop"+(count++)); public voiddestroy() { ta.append("destroy"+(count)+"\n"); System.out.println("destroy"+(count++)); public voidpaint(graphics g) { ta.append("paint"+(count)+"\n"); System.out.println("paint"+(count++)); // Display the string g.drawstring("hello World!", 8, 32); 10

(4) HTML APPLET PARAM (Attribute) code - codebase - codebase HTML archive -.class zip jar Netscape 3.0 align - name - vspace - ( : ) hspace - ( : ) width - ( : ) height - ( : ) 11 (4) Graphics drawxxx( ) drawstring(string msg, int x, int y); drawline(int x1, int y1, int x2, int y2); 12

(4) Graphics drawxxx( ) ( ) drawrect(int x, int w, int h); drawoval(int x, int y, int w, int h); 13 (4) Graphics drawxxx( ) ( ) drawroundrect(int x, int y, int w, int h, int rw, int rh); drawarc(int x, int w, int h, int a, int b); 14

(4) fillxxx( ) fillrect(int x, int y, int w, int h); filloval(int x, int y, int w, int h); fillroundrect(int x, int y, int w, int h, int rw, int rh); fillarc(int x, int y, int w, int h, int a, int b); 15 (5) <APPLET> <PARAM> <HTML> <HEAD> <!-- Generated by Kawa IDE --> <TITLE>Applet Test</TITLE> </HEAD> <BODY> <H1>First Heading</H1> <APPLET CODE=ParameterTest WIDTH=300 HEIGHT=300> <PARAM NAME = LINK0 VALUE = "http://www.yahoo.co.kr"> <PARAM NAME = LINK1 VALUE = "http://www.aiit.or.kr"> <PARAM NAME = LINK2 VALUE = "http://www.soongsil.ac.kr"> <PARAM NAME = LINK3 VALUE = "http://www.daum.net"> <PARAM NAME = LINK4 VALUE = "http://www.javastudy.co.kr"> <PARAM NAME = Title VALUE = "Let's go"> </APPLET> </BODY> </HTML> 16

(6) <APPLET> <PARAM> import java.awt.*; import java.awt.event.*; import java.applet.applet; public class ParameterTest extends Applet { List linklist; Label title; public ParameterTest() { setlayout(new BorderLayout()); linklist = new List(2); linklist.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { ); System.out.println(e); title = new Label("No Title"); add("north", title); add("center", linklist); public void init() { int linkcount=0; String param; while((param=getparameter("link"+linkcount))!= null) { System.out.println(param); System.out.println(param); linklist.add(param); linkcount++; if((param=getparameter("title"))!= null) { title.settext(param); 17 URL getcodebase( ); URL getdocumentbase( ); Image getimage(url url); Image getimage(url url, String name); void resize(dimension d); void resize(int width, int height); AudioClip getaudioclip(url url); AudioClip getaudioclip(url url, String name); static AudioClip newaudioclip(url url); void play(url url, String name); void loop( ); void play( ); void stop( ); 18

<HTML> <HEAD> <!-- Generated by Kawa IDE --> <TITLE>Applet title</title> </HEAD> <BODY> <H1>First Heading</H1> <APPLET CODE=ImageSoundTest WIDTH= 300 HEIGHT= 300> </APPLET> </BODY> </HTML> 19 import java.net.url; import java.awt.*; import java.applet.*; public class ImageSoundTest extends Applet { Image image; AudioClip audioclip, startclip; public void init() { MediaTracker tracker; startclip = Applet.newAudioClip( new URL("canyon.mid")); catch(java.net.malformedurlexception e) { System.out.println(e); public void start() { if(audioclip!= null) audioclip.loop(); if(startclip!= null) startclip.loop(); tracker = new MediaTracker(this); image = getimage(getdocumentbase(), "WuChienLien.jpg"); tracker.addimage(image, 0); try { tracker.waitforall(); catch(interruptedexception e) { System.out.println(e); return; resize(image.getwidth(this), image.getheight(this)); audioclip = getaudioclip(getcodebase(), "AudioClip.au"); try { public void stop() { if(audioclip!= null) audioclip.stop(); if(startclip!= null) startclip.stop(); public void paint(graphics g) { g.drawimage(image, 0, 0, this); 20

drawstring( ) 21 MediaTracker init( ). MediaTracker MediaTracker(Component comp); // // addimage(image image, int id); remove(image(image image); // // 22

1. 2. 1. Void showstatus(string msg); // 2. AppletContextgetApplet( ); // void showstatus(string status); // void showdocument(url url); // URL 23 <HTML> <HEAD> <!-- Generated by Kawa IDE --> <TITLE>Applet title</title> </HEAD> <BODY> <H1>First Heading</H1> <APPLET CODE=AppletBrowserCommTest WIDTH=300 HEIGHT=300> </APPLET> </BODY> </HTML> 24

import java.awt.event.*; import java.net.*; import java.applet.*; public class AppletBrowserCommTest extends Applet { private List urls = new List(4, false); private Choice target = new Choice(); private AppletContext appletcontext=null; public void init() { setlayout(new BorderLayout()); try { ); appletcontext.showdocument(new URL(e.getActionCommand()), target.getselecteditem()); catch(malformedurlexception ee) { appletcontext.showstatus("url Exception: " + ee); add("center", urls); urls.additem("http://park.konkuk.ac.kr"); urls.additem("http://www. konkuk.ac.kr"); urls.additem("http://www. aiit.or.kr"); urls.additem("http://www.sun.com"); urls.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { appletcontext = getappletcontext(); System.out.println(e.getActionCommand()); appletcontext.showstatus("my status: " +e.getactioncommand()+", " +target.getselecteditem()); target = new Choice(); target.add("_self"); target.add("_parent"); target.add("_top"); target.add("_blank"); target.add("new"); add("north", target); 25 HTML <HTML> <HEAD> <!-- Generated by Kawa IDE --> <TITLE>Applet title</title> </HEAD> <BODY> <CENTER> <H1>Communication between Two Applet</H1> <APPLET CODE=MyApplet1 WIDTH=250 HEIGHT=250 NAME = MyApplet1> </APPLET> <APPLET CODE=MyApplet2 WIDTH=200 HEIGHT=50 NAME = MyApplet2> </APPLET> </BODY> </HTML> 26

HTML //MyApplet1.java import java.awt.*; import java.applet.*; public class MyApplet1 extends Applet { public static String myname = "My First Applet" ; Label label; public void init() { setsize(250, 250 ); label = new Label(myName); add(label); public String tostring() { return myname ; // MyApplet2.java import java.awt.*; import java.applet.*; public class MyApplet2 extends Applet { Label label; MyApplet1 anapplet; public void init() { setlayout(new BorderLayout()); setsize(200, 50); for(int i=0;i<10;i++) { try { Thread.sleep(200 ); catch (Exception e) { anapplet=(myapplet1)(getappletcontext().getapplet("myapplet1" )); if(anapplet!= null) { break; System.out. println("applet: "+anapplet+", "+anapplet.tostring()); add("north", new Label("My Second Applet")); if(anapplet!= null) { label = newlabel(anapplet.tostring()); else { label = newlabel("unknown Applet"); System.out. println("label: "+label); add("south", label); 27 AppletContext public AppletContext getapplet( ); public String getappletinfo( ); 28

<HTML> <HEAD> <!-- Generated by Kawa IDE --> <TITLE>Applet title</title> </HEAD> <BODY> <H1>First Heading</H1> <APPLET CODE=BrowserIDTest WIDTH=300 HEIGHT=300></APPLET> </BODY> </HTML> 29 import java.lang.*; import java.util.*; import java.awt.*; import java.applet.applet; public void paint(graphics g) { g.drawstring("browser ID: " + browserid, 10, 20); g.drawstring("getappletcontext(): " + getappletcontext(), 10, 40); g.drawstring("getappletcontext().tostring(): " + getappletcontext().tostring(), 10, 60); g.drawstring("getappletinfo(): " + getappletinfo(), 10, 80); public class BrowserIDTest extends Applet { private String browserid = "Application"; public void init() { String appletcontext = getappletcontext().tostring(); if(appletcontext.startswith( "sun.applet.appletviewer")) { browserid = "Appletviewer"; else if(appletcontext.startswith("netscape.applet.")) { browserid = "Communicator"; else if(appletcontext.startswith("com.ms.applet.")) { browserid = "Internet Explorer"; else if(appletcontext.startswith("sunw.hotjava.tags.tagappletpanel")) { browserid = "HotJava"; else if(appletcontext.startswith("sun.plugin.navig.win32.appletplugin")) { browserid = "Communicator Plugin "; else if(appletcontext.startswith("sun.plugin.ocx.activexapplet")) { browserid = "Internet Explorer Plugin"; System.out.println("browser ID: " + browserid); System.out.println("getAppletContext(): " + getappletcontext()); System.out.println("getAppletContext().toString(): " + getappletcontext().tostring()); System.out.println("getAppletInfo(): " + getappletinfo()); 30

<HTML> <HEAD> <!-- Generated by Kawa IDE --> <TITLE>Applet title</title> </HEAD> <BODY> <H1>First Heading</H1> <APPLET CODE=ScreenSizeTest WIDTH=300 HEIGHT=300></APPLET> </BODY> </HTML> 31 import java.awt.*; import java.applet.applet; public class ScreenSizeTest extends Applet { public void init() { Panel p = new Panel(); Button b1 = newbutton( "B1"); Button b2 = newbutton( "B2"); setlayout(new FlowLayout(FlowLayout.CENTER)); p.add(b1); p.add(b2); add(p); public void paint(graphics g) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle r = getbounds(); g.drawstring("screen size = " + d.width + "x"+ d.height, 10, 100); g.drawstring("location = " + getlocation().x + "," + getlocation().x, 10, 130); g.drawstring("bounds = " + r.x + "," + r.y + "," + r.width + "," + r.height, 10, 150); System.out.println("Screen size = " + d.width + "x" + d.height); System.out.println("Location = " + getlocation().x + "," + getlocation().x); System.out.println("Bounds = " + r.x + "," + r.y + "," + r.width + "," + r.height); 32

JAR(Java Archive) JAR ZIP, 33 JAR(Java Archive) Usage: jar {ctxu [vfm0m] [jar-file] [manifest-file] [-C dir] files... Options: - c(create) - t(table) - u(update) - x(extract) - v - f - m - 0 - M - -C : jar cf MyArchive.jar *.class *.gif *.au jar cvf classes.jar MyClass1.class Myclass2.class jar cvf0 classes.jar MyClass1.class Myclass2.class jar cvfm classes.jar mymanifest C MyDir/. jar tf classes.jar 34

JAR(Java Archive) JAR JAR <APPLET> ARCHIVE JAR 1.1 JAR, <APPLET CODE = Myclass.class ARCHIVE = MyArchive.jar WIDTH = 300 HEIGHT = 300> </APPLET> 35