[英]Java applet will not execute in Safari
初學者Java applet用戶。 我不確定為什么我的小程序不會顯示在頁面中。 我幾乎肯定我擁有所有必要的信息。 是否可能由於使用Safari而無法顯示? 也不會顯示在Chrome中。 看到我想念的東西了嗎? 謝謝
編輯:這>> 在Safari中沙盒化的Java Applet? 也無濟於事。
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>
從類名稱中刪除引號。
更換
<body>
<object code = "JNumberOne.class" width=450 height=100></object>
</body>
用
<body>
<object code = JNumberOne.class width=450 height=100></object>
</body>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.