当我使用 HTML 5 的新对象标签时,我似乎无法让这个 jar 在 html 中运行。我需要添加任何东西才能使其正常工作吗?这是 w3schools 网站上的外观,除了他们将其链接到 .swf 文件。
<object height = "800" width="600" data="ECPrototype.jar"></object>
更新代码:
import java.applet.Applet;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.Timer;
public class EC extends Applet implements ActionListener{
private static final long serialVersionUID = 1L;
Animation test= new Animation();
Timer timer= new Timer(5,this);
Thread thread = new Thread(test);
Thread t = null;
public void init() {
}
public void stop() {
}
public void actionPerformed(ActionEvent e) {
test.move();
test.update();
test.repaint();
}
private class TAdapter extends KeyAdapter implements ActionListener {
public void keyReleased(KeyEvent e) {
test.keyReleased(e);
test.stopAnimation();
}
public void keyPressed(KeyEvent e) {
test.keyPressed(e);
test.startAnimation();
t= new Thread(test.animate);
t.start();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
public EC()
{
thread.start();
timer.start();
JFrame window=new JFrame("EC");
window.setPreferredSize(new Dimension(800,600));
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.add(test);
window.addKeyListener(new TAdapter());
window.setFocusable(true);
window.pack();
window.setVisible(true);
}
public static void main(String args[])
{
new EC();
}
}