Applet in a JFrame?

Hey all, this is my first real posting so I hope that this is in the right section (typical newbie remark).

So I’ve been thinking about how to do this and could not really figure out how. What I want to do is allow people to have the option of playing an applet game on their desktop and not just online. Is this possible? If so, what kind of class would I need to create to properly launch it?


public class MyApplet extends JApplet {

  ...

  public static void main(String[] args) {

    Component applet = new MyApplet();

    JFrame frame = new JFrame("My applet, as application");
    frame.getContentPane().add(applet);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.show();
}

Credits to devx.com

Beware that the usual init(), start(), stop(), and destroy() life cycle methods are NOT called when running it inside a JFrame.

Thank you both for your replies, greatly appreciated :slight_smile:

JFrame.show(), inherited from java.awt.Component, is deprecated, don’t use it!! >:(