targetÀ» ¼³Á¤ÇØ urlÀ» À̵¿ÇÏ´Â ¿¹Á¦
URLTEst.java
import java.awt.event.*;
import java.awt.*;
import java.applet.Applet;
import java.applet.AppletContext;
import java.net.URL;
import java.net.MalformedURLException;
public class URLTest extends Applet implements ActionListener {
private Button urlButton=null;
public void init(){
this.setLayout(new FlowLayout());
this.urlButton = new Button("URLTest");
this.add(urlButton);
this.urlButton.addActionListener(this);
}public void actionPerformed(ActionEvent e) {
Object obj = e.getSource();
AppletContext ac = getAppletContext();
if(obj == urlButton) {
try{
ac.showDocument(new URL(getDocumentBase(),"http://www.jabook.org"), "_blank");
}catch(MalformedURLException e1){}
}
}
}
URLTest.html
<html>
<head><title>URLTest</title></head>
<body>
<applet code="URLTest.class" width=200 height=140></applet>
</body>
</html>
C:\JavaExample\15>javac URLTest.java
AppletContextŬ·¡½ºÀÇ showDocument()¸Þ¼µå¸¦ ÀÌ¿ëÇÏ¿© Ÿ°ÙÀ» ÁÖ¾î URLÀ» ¹Ù²Ü ¼ö ÀÖ´Ù
jabookÀúÀÚ¸íÇÔ |
Á¦¸ñ:¼Ò¼³°°Àº¹Ì´ÏÄÚµå ÀÛ¼ºÀÚ:Àںϸâ¹ö ÀÌÇѼö |