//WelcomeApplet.java
//package c01;
import java.applet.*;
import java.awt.*;
import java.net.*;
public class WelcomeApplet extends Applet
{
public void start()
{
setLayout(new BorderLayout());
Label l= new Label(getParameter("greeting"),Label.CENTER);
l.setFont(new Font("Times", Font.BOLD, 18));
add("Center", l);
Panel p = new Panel();
p.add(new Button("Gary Cornell"));
p.add(new Button("Cay Horstmann"));
add("South", p);
}
public boolean action(Event evt, Object arg)
{
String uName;
URL u;
if(arg.equals("Gary Cornell"))
uName = "www.sina.com";
else if(arg.equals("Cay Horstmann"))
uName = "http://baidu.com";
else return false;
try
{
u = new URL(uName);
getAppletContext().showDocument(u);
}
catch(Exception e)
{
showStatus("Error" + e);
}
return true;
}
}
为什么不可以插入图片呢?
错误:当运行appletviewer的时候,说进读取出现I/0异常:说WelcomeApplet.html系统找不到指定的文件
请大家看看错哪里,我找不出来
[此贴子已经被作者于2007-3-28 15:23:56编辑过]