|
101, Part II: Introduction | Page 2 | Page 3 | Page 4 Part II of the JavaBean tutorial teaches you how to write the code for a simple JavaBean. Later, you will use the BeanBox tool to run, test, and change your Bean. You can also create JavaBeans and modify existing Beans using GUI building tools. For a review of JavaBeans Part I, see JavaBeansTM Part I. A Look at JavaBeans A JavaBean is a Java class that defines properties and that communicates with other Beans via events. Properties can be defined within the JavaBean class definition, or they can be inherited from other classes. A Bean, however, is not required to inherit from any particular class or interface.
JavaBeans that represent graphical components and that are meant to be visible must inherit from a
Note that there are Beans that are not meant to be visible, and they are referred to as invisible Beans. They are identical to other JavaBeans except that they have no GUI representation. They are able to call methods, fire events, save persistent state, and so forth; they just have no screen appearance of their own. Invisible Beans may still be represented visually in a builder tool, and they may be customized within that tool. A Look at Properties Properties are analogous to instance variables inside of objects. Event handlers are analogous to behaviors or methods defined for objects. The main difference is that properties and events are exposed to builder tools to enable visual manipulation of beans. Values assigned to properties can be modified at design time. Similarly you can visually select event handlers from list boxes to link the events generated by one Bean to corresponding event handlers available in another Bean.
When you define properties in a Bean, you typically declare them as Putting It All Together Once you've written the Java class to define a Bean, compile it to verify that you've made no obvious errors in the code. Then, test it using the BeanBox. These steps are explained in detail in the following sections.
Introduction | Page 2 | Page 3 | Page 4
Beth Stearns is the principal partner of ComputerEase Publishing, a computer consulting firm she founded in 1982. Her client list includes Sun Microsystems, Inc., Silicon Graphics, Inc., Oracle Corporation, and Xerox Corporation. Among her publications are the "Java Native Interface" chapter in "The Java Tutorial Continued" book in the Addison Wesley Java series, "The EJB Programming Guide" for Inprise Corporation, and "Understanding EDT", a guide to Digital Equipment Corporation's text editor. Most recently, she is co-author with Vlada Matena of the forthcoming Addison Wesley Java series book, "Applying Enterprise JavaBeans: Component-Based Development for the J2EE Platform." Have a question about programming? Use Java Online Support. | |||||
|
| ||||||||||||