OSGi without the Eclipse
It's become common to equate OSGi with Eclipse or Equinox, but in fact other OSGi implementations exist. This post from JW blogger Oleg Mikheev fills a much needed gap - walking through the process of developing a Hello World bundle with Apache Felix and the IDE of your choice.

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

The applet constructor

A look at the applet constructor's properties and usefulness

QI don't understand what the applet constructor is. Can I override it? Please explain.

ATo write an applet, you must first subclass the Applet class. The Applet class is just like any other class; therefore, an applet constructor is simply the subclass constructor of the Applet class.

Because the applet constructor is just like any other constructor, it cannot be overridden. Constructors perform any necessary initialization for the new object. Remember, you can only override methods, not constructors.

There are five methods in the Applet class that give you the framework on which you build your applet: init(), start(), stop(), destroy(), and paint(). Here, we'll look at the init()) method.

The init() method, which works much like a constructor, handles whatever initialization your applet requires. The browser or applet viewer automatically calls it to perform applet initialization each time the applet is loaded.

In light of this, we recommend that applets do not have constructors because an applet is not guaranteed to have a full environment until its init() method has been called. For example, let's say you want to perform applet image loading inside of an applet constructor. This simply will not work, and should be performed inside the init() method instead.

To sum up, an applet constructor is the constructor of the applet, which has been subclassed from the Applet class. Moreover, this constructor can not be overridden. Therefore, because it is not very useful to define an applet constructor, we advise that you employ an overridden init() method for all initialization.

Author Bio

Random Walk Computing is the largest Java/CORBA consulting boutique in New York, focusing on solutions for the financial enterprise. Known for their leading-edge Java expertise, Random Walk consultants publish and speak about Java in some of the most respected forums in the world.
Resources