初学Java applet用户。我不确定为什么我的applet不会显示在页面中。我几乎肯定我有所有必要的信息。是否有可能因使用Safari而无法显示?也不会出现在Chrome中。你看到我错过了什么吗?感谢
编辑:此>> Java Applet sandboxed in Safari?也无济于事。
Java程序
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Color.*;
public class JNumberOne extends JApplet implements ActionListener
{
Font numberOneFont = new Font("Teen", Font.BOLD, 24);
JButton numberOneButton = new JButton("Who's Number One?");
JLabel numberOneMessage = new JLabel(" ");
Container con = getContentPane();
public void init()
{
numberOneMessage.setFont(numberOneFont);
con.add(numberOneButton);
con.setLayout(new FlowLayout());
con.setBackground(Color.WHITE);
numberOneButton.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
con.remove(numberOneButton);
numberOneMessage.setText("The 1992 Texas Rangers");
con.add(numberOneMessage);
con.setBackground(Color.YELLOW);
validate();
}
}
Applet的HTML
<!DOCTYPE html>
<html>
<head>
<style>
body{text-align:center; background:#00008B;opacity:.5;}
</style>
</head>
<body>
<object code = "JNumberOne.class" width=450 height=100></object>
</body>
</html>
答案 0 :(得分:0)
从类名中删除引号。
替换
<body>
<object code = "JNumberOne.class" width=450 height=100></object>
</body>
使用
<body>
<object code = JNumberOne.class width=450 height=100></object>
</body>