为什么我的Java Applet程序运行时,提示:小程序未初始化
------ WelcomeApplet.java ----------
mport java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import com.sun.corba.se.spi.ior.MakeImmutable;
public class WelcomeApplet extends JApplet {
public void init(){
EventQueue.invokeLater(new Runnable(){
public void run(){
setLayout(new BorderLayout());
JLabel label = new JLabel(getParameter("greeting"),SwingConstants.CENTER);
label.setFont(new Font("Serif",Font.BOLD,18));
add(label,BorderLayout.CENTER);
JPanel panel = new JPanel();
JButton cayButton = new JButton("Cay Horstmann");
cayButton.addActionListener(makeAction("http://www.horstmann.com"));
panel.add(cayButton);
JButton garyButton = new JButton("Gary Cornell");
garyButton.addActionListener(makeAction("mailto:gary_cornell@apress.com"));
panel.add(garyButton);
add(panel,BorderLayout.SOUTH);
}
});
}
public ActionListener makeAction(final String urlString){
return new ActionListener(){
public void actionPerformed(ActionEvent event){
try {
getAppletContext().showDocument(new URL(urlString));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
}
}
-------- WelcomeApplet.html -----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>WelcomeApplet</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<hr/>
<p>
This is Applet is from the book
<a href="http://www.horstmann.com/corejava.html">Core Java</a>
by <em>Cay horstmann</em> and <em>Gary Cornell</em>,
published bu Sun MicroSystems Press.
</p>
<applet code="WelcomeApplet.class" width="400" height="200" alt="">
<param name="greeting" value="Welcome to Core Java!"/>
</applet>
<hr/>
<p>
<a href="WelcomeApplet.java">The Source.</a>
</p>
</body>
</html>