>An applet can be loaded as any other component and added to a container
>within an app, but many applets expect the browser to be there and
>consequently trying to run the applet will cause it to fail. Has anyone
>found a way to "trick" an applet into thinking it is running inside a
>browser/appletviewer?
A very simple trick is just to write a main method that calls init and
start. See http://mindprod.com/jgloss/applet.html That will fool
most garden variety Applets.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Jeremy - 21 Aug 2003 07:40 GMT
Thanks for your prompt reply. I have gotten this far, but there are many
problems with just using the init() and start() methods, and many applets,
even seemingly simple ones (for example, the Rubix Cube applet that I tested
this with) will fail unless they were specifically written to be able to run
in this environment.
-Jeremy
> >An applet can be loaded as any other component and added to a container
> >within an app, but many applets expect the browser to be there and
[quoted text clipped - 9 lines]
> Coaching, problem solving, economical contract programming.
> See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
> An applet can be loaded as any other component and added to a container
> within an app, but many applets expect the browser to be there and
> consequently trying to run the applet will cause it to fail. Has anyone
> found a way to "trick" an applet into thinking it is running inside a
> browser/appletviewer?
The trick is rather old: You emulate an Applet environment to the
extend that is needed by your Applet. The resulting program is
sometimes called a hybrid, because it can run as an application and an
applet.
The following article has some 250 lines of code of such a hybrid,
emulating most or all of what an applet needs:
http://www.javaworld.com/javaworld/jw-11-2000/jw-1103-java101.html
And
http://www.acme.com/java/software/Acme.MainFrame.html
is another implementation (afaik the later is a little bit old).
/Thomas
Jeremy - 21 Aug 2003 07:40 GMT
Thanks for the reply. This is a very interesting article and the AppletStub
interface was the missing piece of the puzzle in my problem :-)
-Jeremy
> > An applet can be loaded as any other component and added to a container
> > within an app, but many applets expect the browser to be there and
[quoted text clipped - 19 lines]
>
> /Thomas