简体   繁体   English

Java applet麻烦,真的很简单

[英]Java applet trouble, really simple

I just started learning Java and I encountered some problems with the tag in HTML. 我刚开始学习Java,并且在HTML中使用标记遇到了一些问题。 Actually I think it's because of the attribute classid, I think I'm not using it correctly. 实际上,我认为这是由于属性classid引起的,我认为我没有正确使用它。 I had some experience with HTML/CSS/Javacript/PHP some time ago so I can say that I can manage those. 一段时间以前,我在HTML / CSS / Javacript / PHP方面有一些经验,所以可以说我可以管理这些东西。

I have this Java code: 我有这个Java代码:

import java.awt.Graphics;
import java.applet.Applet;

public class app2 extends Applet {
    public void paint(Graphics g){
        g.drawString("This is an applet",50,50);
    }
}

And I have this in HTML: 我在HTML中有这个:

    <html>
    <head>
        <title> First applet </title>
    </head> 
    <body> 
        <object codetype="application/java" 
            classid="java:app2.class"
            width="300" height="150" ></object>
    </body>
</html>

Both app2.class and the html file are in the same folder, but when I open the HTML file it doesn't show anything. app2.class和html文件都在同一文件夹中,但是当我打开HTML文件时,它什么也没有显示。 Using the deprecated tag, works though. 使用不推荐使用的标签,虽然可以。 Could you please tell me what's wrong with this? 你能告诉我这是怎么了吗?

You have created the object tag incorrectly. 您创建的对象标签不正确。 See this link for more information on embedding applets in html pages. 在HTML页面中嵌入的applet的链接以获取更多信息。

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

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