嵌入 Java Applet [英] Embedding a Java Applet

查看:23
本文介绍了嵌入 Java Applet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 Java Applet 显示在网页上.小程序在 Eclipse 中运行,但在网页上不执行任何操作.供参考的是小程序(不,它不完整):

I'm trying to get a Java Applet to display on a webpage. The applet runs in Eclipse, but does nothing on the webpage. For reference here is the applet (no, it's not complete):

package TestProg.webClient;

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

public class UserLogin extends Applet {
    String accountId = "";

    public void init() {
        TextField username = new TextField(10);
        TextField password = new TextField(10);
        Button login = new Button("   Log In   ");
        add(username);
        add(password);
        add(login);
    }
}

这里是 HTML 代码:

And here is the HTML code:

<body>
  <center>
    <div id="title"><h1>UserLogin</h1></div>
  </center>
  <applet code="sp.jar" width="400" height="100" alt="This isn't working"></applet>
</body>

我也试过用 嵌入,在 Linux 机器上尝试过 Chrome 和 Firefox,出于某种原因从 .jar 中取出 .class 文件并尝试这样做.网页上绝对没有显示任何内容.

I've also tried embedding with <object> and <embed>, have tried with both Chrome and Firefox on a Linux machine, and for some reason took the .class file out of the .jar and tried that. Absolutely nothing displays on the webpage.

任何帮助将不胜感激.理查德

Any help would be greatly appreciated. Richard

推荐答案

我发现了问题所在,而且似乎严重缺乏这方面的知识......

I discovered what the problem was, and there seems to be a severe lacking of this knowledge out there....

HTML 标签应该看起来像这样...

The HTML tag should look like this...

感谢所有帮助...

这篇关于嵌入 Java Applet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆