abraabra
abraabra

Reputation: 474

How to start a java applet from code?

Let's suppose I have something like:

Applet myApplet = new MyApplet();

How can I invoke that applet in a way that a new window appears, and I am still able to access that MyApplet instance from that scope?

In general, I want to be able to write code like this:

class Runner {
    public static void main(String[] args) {
        new Runner().run();
    }

    void run() {
        MyApplet myApplet = new MyApplet();
        myApplet.init();
        myApplet.doSomething();
    }
}

How can I do it?

Upvotes: 1

Views: 451

Answers (2)

Alexei Kaigorodov
Alexei Kaigorodov

Reputation: 13535

This question is answered elsewhere, for example, at http://www.dreamincode.net/code/snippet1607.html

I found it via https://www.google.ru/search?q=java+applet+%22as+application%22

Upvotes: 1

Emmanuel Bourg
Emmanuel Bourg

Reputation: 11058

You have to provide an implementation of java.applet.AppletStub to your applet. The stub provides context information that simulates the behavior of a web browser.

Upvotes: 0

Related Questions