我想在C:\Dev\SSIS 70.23
C:\Dev\SSIS\DatabaseCleanup 17.80
C:\Dev\SSIS\DatabaseMaintTests 22.91
C:\Dev\SSIS\EclipseKeys 1.22
C:\Dev\SSIS\TemplateProject 13.29
中运行applet
。我的项目目录具有以下结构:
appletviewer
AppletDocumentLoader是我的项目,然后在/home/sanctus/workspace/AppletDocumentLoader/bin/com/examples/ti
中有3个类文件和HTML文件即。全部在同一目录中。
我的src课程
/bin/com/examples/ti
我的HTML文件
package com.examples.ti;
import java.applet.AppletContext;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class Applet extends JApplet {
private static final long serialVersionUID = -8756947240188460854L;
public void init() {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JLabel label = new JLabel("Hello World");
add(label);
JButton openDocument = new JButton();
openDocument.setText("Button");
openDocument.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("BUTTON CLICKED");
AppletContext appletContext = getAppletContext();
try {
appletContext
.showDocument(
new URL(
"http://www.google.com"),
"_self");
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
}
});
add(openDocument);
}
});
} catch (InvocationTargetException | InterruptedException e) {
e.printStackTrace();
}
}
}
我得到的错误:
<!DOCTYPE html>
<html>
<head>
<title>Hi there</title>
</head>
<body>
This is a page
a simple page
</body>
<applet code="Applet.class"
archive="Applet.jar"
width=350 height=350>
</applet>
</html>
答案 0 :(得分:2)
applet标记的code参数应该是Java类的全名,因此com.examples.ti.Applet
。见Applet code tags and class files