Bean Internals  «Prev 

Programmatic use of Properties

The most straightforward way to use properties is to work directly with accessor methods.
An accessor method is a method that is usually small, simple and provides the means for the state of an object to be accessed from other parts of a program. Although it introduces a new dependency, use of the methods are preferred to directly accessing state data because they provide an abstraction layer.

Properties, events, and methods

The three most important features of a Java Bean are the set of properties it exposes, the set of methods it allows other components to call, and the set of events it fires. Properties are described in more detail later. Basically properties are named attributes associated with a bean that can be read or written by calling appropriate methods on the bean. Thus for example, a bean might have a "foreground" property that represents its foreground color. This property might be read by calling a Color getForeground() method and updated by calling a void setForeground(Color c) method. The methods a Java Bean exports are just normal Java methods which can be called from other components or from a scripting environment. By default all of a bean's public methods will be exported, but a bean can choose to export only a subset of its public methods
Events provide a way for one component to notify other components that something interesting has happened. Under the new AWT event model an event listener object can be registered with an event source. When the event source detects that something interesting happens it will call an appropriate method on the event listener object.

Developing Java Beans