±Û¾´ÀÌ :À±Áö¼ö 1998³â 9¿ù 10ÀÏ 05:15:26
In Reply to: [Q]ÀÏÁ¤½Ã°£ ÈÄ¿¡ ÀÚµ¿À¸·Î ³Ñ¾î°¡´Â ¾ÖÇø´ ¹æ¹ýÁ»... posted by À̱¤¼ö on 1998³â 9¿ù 07ÀÏ 17:06:57:
´ÙÀ½¼Ò½º´Â ´Ù¼¸°³ÀÇ À̹ÌÁö¸¦ ¾Ö´Ï¸ÞÀ̼ÇÇÏ°í
ÀÏÁ¤½Ã°£ÀÌ Áö³ª¸é ´Ù¸¥ À¥»çÀÌÆ®·Î ³Ñ¾î °¡´Â°ÅÁÒ..
´Ù¸¥ À¥»çÀÌÆ®¿¡ ¾ÖÇø´À» Áý¾î ³ÖÀ¸¸é ´ÙÀ½ ¾ÖÇø´ÀÌ µÇ°ÚÁÒ..
±×¸®°í À̹ÌÁö¸¦ ¿ÏÀü·Îµù½ÃÅ°±âÀ§ÇØ ½Ã°£À» ¹ú±â À§Çؼ
MediaTracker¿¡ À̹ÌÁöµéÀ» Áý¾î³Ö°í WaitForAll¸¦ ÅëÇØ ·ÎµùÀÌ µÉ¤¨¤Â ±îÁö ±â´Ù¸®ÁÒ..
import java.net.*;
import java.awt.*;
import java.applet.*;
public class ExampleApplet extends Applet implements Runnable
{
Image anim[];
MediaTracker tracker;
Thread imgthread;
int currentimg;
URL url;
AppletContext ac;
public void init()
{
ac=getAppletContext();
Label lable=new Label("ÀÌ°ÍÀº ¸±·Îµù Å×½ºÆ®");
resize(200,200);
add(lable);
try {
url=new URL("http://www.buyer.co.kr/main.htm");
}catch(MalformedURLException e) {}
}
public void start()
{
if(imgthread!=null)
{
imgthread=new Thread(this);
imgthread.start();
}
}
public void stop()
{
try {
Thread.sleep(10*1*1000);
//ÀÏÁ¤½Ã°£ ±â´Ù¸²
ac.showDocument(url);
}catch (InterruptedException e) { stop(); }
if(imgthread!=null)
{
imgthread.stop();
imgthread=null;
}
}
public void run() {
currentimg=0;
anim= new Image[5];
tracker=new MediaTracker(this);
for (int i = 0; i<5; i++) {
anim[i] = getImage(getCodeBase(),"images/anim"+i+".gif");
tracker.addImage(anim[i],0);
}
try {
tracker.waitForAll();
//·ÎµùµÉ¤¨¤Â °¡Áö ±â´Ù¸²
if(tracker.isErrorAny()) {
// ·ÎµùÁß ¿¡·¯ ¹ß»ýÈ®ÀÎ
ac.showStatus("À̹ÌÁö·ÎµåÁß¿¡·¯");
return;
}
} catch (InterruptedException e) {
}
repaint();
while(true)
{
try {
DisplayImage(this.getGraphics());
currentimg++;
if(currentimg==5) break;
Thread.sleep(1000);
} catch (InterruptedException e)
{ stop(); }
} // while end
}// run end
public void DisplayImage(Graphics g)
{
g.drawImage(anim[currentimg],10,10,null);
}
public void paint(Graphics g)
{
g.drawString("À̹ÌÁö ·ÎµùÁß",10,20);
}
}
´ëÃæ µÈ°Í °°Àºµ¥ ¾Ö´Ï¸ÞÀ̼ÇÀÌ À߾ȵǴ °Í °°±âµµ ÇÏ°í
¿ä ¾Æ¹«Æ° µµ¿òÀÌ µÇ¾úÀ¸¸é Çϳ׿ä.