Java – does the applet not display at all?

OK, so I did a small applet tutorial. I read the init () method required to run the applet Such is the case. At least in my IDE (eclipse) When I try to execute < applet >, the applet viewer has no problem running my applet Tags in HTML don't show anything, but they act like something (the text position is changed by tags) This 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);
    }
}

This is the code I use on my web page:

<applet code="Applet.class" width=100 height=100></applet>

Even if I delete the width / height parameter, I get the same result (it won't appear on the page) Yes, the path of the applet is correct and located 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 searching the console, I found this:

Could not read chrome manifest file '/usr/lib/firefox-8.0/extensions
/{972ce4c6-7e08-4474-a285-3208198ce6fd}/chrome.manifest'.

Solution

The applet tag is not recommended, but the object tag should be used Some browsers don't support applet tags, which may be why you can't see applets, and object tags can now be used for almost all of these tags

Edit: provide code examples:

<OBJECT codetype="application/java"
        classid="java:Applet.class"
        width="500" height="500">
My first Java applet.
</OBJECT>

For more examples and information, see this link and this link

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>