Re: JFrame as JApplet?



Thomas Weidenfeller wrote:
polsa wrote:

I was wondering if there is any way to write an application which can
be run as well as a JFrame as as a JApplet. And if so: how can I figure
out which way the application has been started?


If main() is called, then it was started as an application. I haven't done this in ages, but the following should start the applet when it is called as an application:

public class MyAppletStub implements AppletStub {
// implement all AppletStub methods here
public MyAppletStub(String args[]) {
// parse and remember command line
}
}


    public static void main(String args[]) {
        JApplet a = new MyJApplet();
        a.setStub(new MyAppletStub(args));
        a.init();
            a.start();
    }

There are other things which might need to be adjusted. My notes tell me that I got the above from some Sun article, but I can't find the original article at the moment.
Seems that you refer to this article:
http://java.sun.com/developer/technicalArticles/Programming/TurningAnApplet/


Maybe you probably better use Sun's AppletViewer to run the applet as an application.


/Thomas


-- "Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

.