ShowBean class of Chapter 11 is a simple beanbox
for displaying and experimenting with individual beans.
ShowBean code listed in Example 11-30 is concerned
primarily with the creation of a GUI, and the key bean-manipulation
methods are handled by a separate
Bean class. Now that we’ve seen how to write
a bean and its auxiliary classes, we’re ready to tackle this
Bean class itself; it is listed in Example 15-10.
An instance of the
represents a single bean and its associated
Bean defines methods for querying and
setting bean properties and for querying and invoking bean commands.
(It defines a command as a method with no arguments and no return
values.) In some ways,
Bean can be
considered a simplified interface to the
BeanInfo class. Note that the
java.beans package does not define any class named
Bean: JavaBeans are not required to
Bean interface or
Bean superclass, so
we’ve appropriated this class name for our own use here.
Bean class has a public
constructor that uses the
java.beans.Introspector class to obtain
BeanInfo for the bean object you pass to it.
Bean also defines three static factory
methods that you can use to instantiate the bean object instead of
creating it yourself:
) instantiates a named class to create the bean;
fromSerializedStream( ) reads a serialized bean object from a
java.io.ObjectInputStream (see Chapter 10);
uses the JavaBeans persistence ...