Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2003

Tip: Looking for answers? Try searching our database.

An applet within an app

Thread view: 
Jeremy - 21 Aug 2003 05:22 GMT
Hello,
I'm trying to figure out how to make an applet work reliably inside of a
java app.  I know this must be possible - after all, AppletViewer is written
in java (although perhaps uses JNI?)

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?

Thanks,
-Jeremy
Roedy Green - 21 Aug 2003 05:26 GMT
>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.
Thomas Weidenfeller - 21 Aug 2003 07:07 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.