嵌入Java小程序 [英] Embedding a Java Applet

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

问题描述

我想获得一个Java小程序,以显示在网页上。小程序在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 code:

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>

我也试过用&LT嵌入;对象&gt; &LT;嵌入&GT; ,都与两个尝试Chrome和Firefox在Linux计算机上,由于某种原因把.class文件出的.jar和试过了。
绝对没有显示在网页上。

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.

任何帮助将大大AP preciated。
理查德

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...

&LT;小程序code = NameOfPackage.NameOfApplet存档= NameOfApplet.jar WIDTH = 300 HEIGHT = 300&GT;

感谢所有谁帮助...

Thanks to all who helped...

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

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