JAVA-MANI.BLOGSPOT.COM
Thursday, June 26, 2008

Life Cycle of an Applet


Each Java applet goes through a sequence of stages. They are created (initialized), displayed (painted), paused while off screen (stopped,started) and finally removed (destroyed) when over.

Initialization occurs when the applet is first loaded. Tasks performed here are creating objects,setting initial state, loading images, fonts, etc. and setting parameters. The method used is init()

Display is how things are drawn on screen whether it is text, graphics or background. Redisplay occurs many time through the life of an applet. The method used is paint().

Stopping occurs when one leaves a page that contains a running applet. Threads normally continue running but can be manually stopped. The method used is stop().

Starting occurs after initialization and after stops occur. Tasks include starting threads, sending messages to helper objects, or to tell the applet to start running. The method used is start().

Destruction cleans up an applet before the browser exits. Tasks include thread stopping. Normally the method destroy() is not overridden.



Cautions About Applet Use


The greatest problem with using applets is the nonstandard way browsers cope with them. Some browsers support Java natively (ie. self contained). However this leads to version compatibility issues. Other browsers allow applets to be passed through to the Java engine of the viewer's operating system. But this requires that the viewer download and install Java. Are your website visitors this sophisticated? And finally there are ancient browsers like MSIE6 which really makes you jump through the hoops to hook up an installed Java environment. Most browsers also open a box that will overwrite any text that the box is scrolled to (ie a hign z-index value). At this point Java Script looks like a more consistent method of utility delivery!

For security purposes, Java applets allow NO access to user resources! Local files can not be accessed. Printers can't be used. Only the current website server can be communicated with. If your project can live with those restrictions then an applet may be more appropriate than an application.

0 comments:

SUBSCRIBE VIA eMAIL

Enter your email address:

Delivered by FeedBurner

Recent Posts

Firefox 3

Counter

internet companies

Live Traffic Map

Subscribe Now