appletStub°ú parameter°ªÀ» ÀÌ¿ëÇØ¼ ¾ÖÇø´ ³»¿¡¼ ´Ù¸¥ ¾ÖÇø´À» ·ÎµùÇÏ´Â ¿¹Á¦
QLoader.java
import java.applet.Applet;
import java.applet.AppletStub;
import java.awt.*;
public class QLoader extends Applet implements Runnable, AppletStub {
String appletToLoad;
Thread appletThread;
public void init() {
appletToLoad = getParameter("appletToLoad");
setBackground(Color.white);
}
public void paint(Graphics g) {
g.drawString("Loading the BIG ONE ...", 30, 30);
}
public void run() {
try {
Thread.sleep(1000);
Class appletClass = Class.forName(appletToLoad);
Applet realApplet = (Applet)appletClass.newInstance();
realApplet.setStub(this);
setLayout( new GridLayout(1,0));
add(realApplet);
realApplet.init();
realApplet.start();
}
catch (Exception e) {
System.out.println( e );
}
validate();
}
public void start(){
appletThread = new Thread(this);
appletThread.start();
}
public void stop() {
appletThread = null;
}
public void appletResize( int width, int height ){
resize( width, height );
}
}
SecondApplet.java
import java.awt.*;
import java.applet.*;
public class SecondApplet extends Applet {
TextField tf;
public void init() {
System.out.println("Starting Second applet");
String s;
tf = new TextField( 10 );
add( tf );
s = getParameter("SecondAppletParm");
tf.setText(s);
}
}
TestQuick.html
<HTML>
<HEAD>Quick Loader</HEAD>
<BODY>
<APPLET CODE="QLoader.class" NAME="QLoader" HEIGHT=200 WIDTH=200>
<PARAM NAME="appletToLoad" VALUE="SecondApplet">
<PARAM NAME="SecondAppletParm" VALUE="Hello World">
</APPLET>
</BODY>
</HTML>
C:\JavaExample\15>javac QLoader.java
C:\JavaExample\15>javac SecondApplet.java
C:\JavaExample\15>appletviewer TestQuick.html
AppletStubÀÎÅÍÆäÀ̽º¸¦ ±¸ÇöÇÏ¸é ¾ÖÇø´ÀÇ Å©±â¸¦ Á¶ÀýÇÒ ¼ö ÀÖÀ¸¸ç, ½º·¹µå¿Í ¾ÖÇø´ÀÇ ÆÄ¶ó¹ÌÅ͸¦ ÀÌ¿ëÇÏ¿© ´Ù¸¥ ¾ÖÇø´À» ·ÎµùÇÒ ¼ö ÀÖ´Ù
jabookÀúÀÚ¸íÇÔ |
Á¦¸ñ:¼Ò¼³°°Àº¹Ì´ÏÄÚµå ÀÛ¼ºÀÚ:Àںϸâ¹ö ÀÌÇѼö |