Working with Java Beans

A short tutorial based on the NetBeans IDE

Java Beans is a component technology on top of the Java programming language that tries to simplify programming by reducing it as far as possible to simple graphical operations. It is used mainly to implement graphical user interfaces, but can be applied to the non-graphical parts of a program as well. To work with Java Beans one needs an appropriate tool like a Java IDE ("Integrated Development Environment") and a set of components, the beans.

In this tutorial we will use the free NetBeans IDE and the Swing beans that are part of the standard Java libraries to create a very simple example applet. Fur further information on how to use beans, how to program them yourself or how to better integrate them into an IDE, consult Sun's Java Beans homepage or one of the many books about advanced Java programming.

The tutorial will explain all necessary steps to create the demo applet with NetBeans 3.6, so by simply following all instructions, you should finally get an html page with a working applet. Since we use only basic operations it should work with older (and hopefully newer) versions of NetBeans. Other IDEs like JBuilder can be used as well, but though the principal tasks are the same, the detailed instructions will of course vary. For a deeper understanding of the programming environment consult the documentation coming with NetBeans or the NetBeans book from Boudreau, Glick and Greene (ISDN 0-596-00280-7).

The example program is a simple calculator with two input fields for entering numbers, four buttons with the basic arithmetic operations and an output field displaying the result:

The construction of the applet proceeds with the following steps: