【问题标题】:Running basic applet in browser(chrome)在浏览器中运行基本小程序(chrome)
【发布时间】:2017-01-22 08:50:11
【问题描述】:

我是小程序编程的新手。 当我在小程序查看器中运行我的代码时它可以工作,但是当我在浏览器中运行它时它不起作用(它显示一个空白的白色网页) 这是我的代码。

    import java.awt.*;
    import java.applet.*;

    public class BannerApplet extends Applet implements Runnable
     {
        String msg= "A simple moving Banner";
        Thread t=null;
        int state;
        boolean stopFlag;

        public void init()
      {
         setBackground(Color.cyan);
         setForeground(Color.red);
      }

        public void start()
       {
          t=new Thread(this);
          stopFlag=false;
          t.start();
       }

        public void run()
       {
       char ch;
        for(int i=0;i<100;i++)
      {
         try
         {
            repaint();
            Thread.sleep(250);
            ch=msg.charAt(0);
            msg=msg.substring(1,msg.length());
            msg+=ch;
            if(stopFlag)
                break;
        }
        catch(InterruptedException e){

        }
    }
}

     public void stop()
{
    stopFlag=true;
    t=null;
}

       public void paint(Graphics g)
      {
           g.drawString(msg,50,30);
          showStatus("this is a message box");
        }
     }

这是我的 html 代码。

     <!DOCTYPE html>
     <html>
     <title>
        applet window
     </title>`
      <body>
     <applet code="BannerApplet.class" width=300 height=100>
     </applet>
      </body>
    </html>

【问题讨论】:

标签: java html applet


【解决方案1】:

自 2015 年 9 月(Chrome 版本 45)起,Chrome 不再支持 Java 小程序。

https://java.com/en/download/faq/chrome.xml

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-20
    • 1970-01-01
    • 1970-01-01
    • 2011-09-23
    • 1970-01-01
    • 2017-05-29
    • 2011-10-26
    相关资源
    最近更新 更多