简体   繁体   English

Java Applet将无法在Safari中执行

[英]Java applet will not execute in Safari

Beginner Java applet user. 初学者Java applet用户。 I'm not sure as to why my applet will not display in a page. 我不确定为什么我的小程序不会显示在页面中。 I'm almost positive I have all necessary information. 我几乎肯定我拥有所有必要的信息。 Is it possible that it will not show up due to using Safari? 是否可能由于使用Safari而无法显示? Will not show up in Chrome, either. 也不会显示在Chrome中。 Do you see what I'm missing? 看到我想念的东西了吗? Thanks 谢谢

EDIT: This >> Java Applet sandboxed in Safari? 编辑:这>> 在Safari中沙盒化的Java Applet? doesn't help, either. 也无济于事。

Java program 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();
   }
  }

HTML for Applet 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>

Remove the quotes from the class name. 从类名称中删除引号。

Replace 更换

 <body>
       <object code = "JNumberOne.class" width=450 height=100></object>
 </body>

With

 <body>
       <object code = JNumberOne.class width=450 height=100></object>
 </body>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM