Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a JFrame application working nicely. However now I'd like to run it on the web as an Applet. This is what I've done:

import MyPackage.*;

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;

public class MyName extends JApplet
{

     public void init() {
        setSize(600,450);
        new MyName()
     }

    public MyName() {
        JShellFrame frame = new JShellFrame(true, null, null);
        frame.setVisible(true);
    }

}

How can I make an html file to run this applet? Also, I have an external jar file that the applet will need. Does the applet not need a main method?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
294 views
Welcome To Ask or Share your Answers For Others

1 Answer

Check out Getting Started With Applets. It covers relevant methods and life cycle. It mentions main method as well:

Unlike Java applications, applets do not need to implement a main method.

Deployment section covers HTML file details. For dependency jars you can specify more than one jar in archive attribute of applet tag.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...