A property is a named attribute of a Bean. Nearly every class has properties—size, color, and font, for example. The usual Java coding convention is to manipulate properties via a pair of methods, set and get. For example, all Component classes have a Foreground property; you can obtain the current foreground color with the getForeground method and change it with the setForeground method. Although this coding convention (using getX and setX methods for property X) is strongly suggested for all Java classes, Java Beans must follow this style of coding so that a Bean container can easily identify properties by examining method names. The process of identifying a Bean’s properties is known as introspection. Introspection automatically determines the characteristics of a Bean by examining the bean’s definition.
Not every property supports both get and set methods; some properties are read-only values and have only get methods. Properties also come in two basic types:
A simple property represents a single value; the name of the property can be derived from its methods. For example, the getStyle and setStyle methods imply the existence of a property named Style. If a simple property is read-only, it will have only a get method; a few properties are write-only and support only set methods.
An indexed property represents an array of values; like a simple property, an indexed property is manipulated with set and get methods. Some indexed property methods require the specification of an array index and allow changes to only one element; other indexed properties allow you to set or get the entire array.
Simple and indexed properties can also be bound or constrained, as described in the next two sections.