Properties and Customizers
Properties represent the “state” or “data” content of a
bean. These features can be manipulated externally to configure the bean.
For a bean that’s a GUI component, you might expect its properties to
include its size, colors, and other features of its basic appearance.
Properties are similar in concept to an object’s public variables. Like a
variable, a property can be a primitive type (such as a number or
Boolean), or it can be a complex object type (such as a String or a collection of spreadsheet data).
Unlike variables, properties are always manipulated using methods to set
and get the value; this enables a bean to take action whenever a property
changes. By sending an event when a property changes, a bean can notify
other interested beans of the change (which we will discuss later in this
chapter).
Let’s pull a couple of beans into NetBeans and take a look at their
properties. Click on a button (this will be a JButton) from the Swing Controls group of the
palette, and then click in the workspace. When the JButton was first loaded by NetBeans, it was
inspected to discover its properties. When we select an instance of the
button, NetBeans displays these properties in the Properties pane and
allows us to modify them.
The button has about eight basic properties, followed by a few
additional groupings. The list called Other Properties adds more detail.
There is also a Layout properties section (these are in actuality not
properties of the JButton, but are ...