爪哇 - 小程序根本就没有显示? [英] Java - Applet simply not displaying?
问题描述
好了,所以我做了一个小程序,教程,和我读了一个小程序来运行的init(需要)
方法。而且它。至少在我的IDE(Eclipse的)。 Applet查看器有经营我的小程序,当我尝试做&LT没有问题;小程序>在HTML
标签,没有显示器,但它的作用就好像东西是存在的(文字位置由标签改变)。这是我的小程序:
进口java.awt中的*。
进口的javax.swing *。公共Applet类扩展JApplet的{
公共无效的init(){
标签标签=新标签(你好!);
this.add(标签);
}
}
这是code我用在我的网页:
<小程序code =Applet.classWIDTH = 100 HEIGHT = 100>< /小程序>
即使我删除宽度/高度参数,我得到相同的结果(它不会在页面上显示)。是,路径到小程序是正确的,在同一目录中。谢谢你的帮助。
如果有帮助,这是我的 DOCTYPE
:
<!DOCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0 Strict标准// ENhttp://www.w3.org/TR/xhtml1/DTD/ XHTML1-transitional.dtd>
最后,淘控制台后,我发现这一点:
无法读取铬清单文件'/usr/lib/firefox-8.0/extensions
/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.manifest。
小程序
标签去precated和 对象
标记应改为使用。在小程序
标记不被一些浏览器支持这可能是为什么你不能看到小程序,而对象
标记应该以pretty工作得个个这些日子。
修改:提供code例如:
<对象codeTYPE =应用程序/ JAVA
CLASSID =java的:Applet.class
WIDTH =500HEIGHT =500>
我的第一个Java小程序。
< /对象>
Okay, so I did a little applet tutorial, and I read that the init()
method is required for an applet to run. And it does. At least in my IDE (Eclipse). The Applet Viewer has no problems running my applet, when I try to do the <applet>
tag in HTML, nothing displays, but it acts as though something is there (text position is altered by the tag). Here is my applet:
import java.awt.*;
import javax.swing.*;
public class Applet extends JApplet{
public void init(){
Label label = new Label("Hello!");
this.add(label);
}
}
And this is the code I'm using on my webpage:
<applet code="Applet.class" width=100 height=100></applet>
Even if I remove the width/height parameters, I get the same result (it doesn't display on the page). Yes, the path to the applet is correct and in the same directory. Thank you for your help.
If it helps, this is my DOCTYPE
:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Finally, after scouring the console, I found this:
Could not read chrome manifest file '/usr/lib/firefox-8.0/extensions
/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.manifest'.
The applet
tag is deprecated and the object
tag should be used instead. The applet
tag is not supported by some browsers which is probably why you cant see the applet, whereas the object
tag should work with pretty much all of them these days.
Edit: Provide code example::
<OBJECT codetype="application/java"
classid="java:Applet.class"
width="500" height="500">
My first Java applet.
</OBJECT>
See this link and this link for further examples and information.
这篇关于爪哇 - 小程序根本就没有显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!