Java Reference
In-Depth Information
9. Load this JAR file into the Bean Builder. Place a Stock object in the
design window along with two JList components.
10. Set up the event handling so that when the price of the stock goes
up, the prices appears in one list, and when the price goes down, it
appears in the other list. Thus, one list will grow only when the
price goes up, and the other list will grow only when the price goes
down.
11.
Change the price of the Stock bean to verify that the events are
working properly.
When you change the price of the stock so that it goes up, you should
see the new price in the list you denoted for price increases. When the
price goes down, you should see the new price in the other list.
Summary
A JavaBean is a reusable software component designed to be used
either in a GUI bean builder tool or in other Java technologies such as
JavaServer Pages.
■■
A JavaBean is a class that adheres to the JavaBeans specification. For
example, the class must implement the java.io.Serializable interface and
contain a public no-argument constructor.
■■
JavaBeans have three basic components: properties, events, and meth-
ods. Each of these features of a JavaBean is determined by the public
methods declared within the class.
■■
A bean's properties are determined by the public set and get methods
in the class.
■■
A bean's events are determined by the public add<event_name>Lis-
tener() and remove<event_name>Listener() methods in the class.
■■
Beans are deployed by placing them in a JAR file with a corresponding
manifest file that lists the beans in the JAR file.
■■
The Bean Builder is a free tool available from Sun that allows you to test
and work with JavaBeans.
■■
Bound properties allow a bean to have its properties bound to the prop-
erties of another bean. Constrained properties allow a bean to have a
property verified before any changes are made to the property. Con-
strained listeners have the option of vetoing any changes to a property.
■■
Search WWH ::




Custom Search