繁体   English   中英

Java Applet将无法在Safari中执行

[英]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.

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