Editing a Bean’s Properties

The editable properties for the currently selected Bean are shown on the property sheet. Each property is shown with its name and associated property editor. Some editors allow you to interact directly, while others launch a separate editor window for the property. The editor that is provided is specific to the data type of the property. For instance, a string property editor allows you to edit the value by entering the new string. A color property editor paints its area of the display with the selected color. When you click on the color editor, a dialog box appears that allows you to enter a color according to an RGB triple, or by selecting from a list of predefined color names.

When the instance of the ExplicitButton Bean is selected, the property sheet shows its editable properties as shown in Figure 7.5. Edit the label property for the button so that it contains the string Start. As you edit the property, the changes are reflected immediately on the button.

The button’s editable properties

Figure 7-5. The button’s editable properties

You should play around a little with the various property editors to see how they work. In a later chapter, we will create our own custom property editors. The size of the property sheet will grow and shrink as needed to accommodate the number of editable properties for the selected Bean. Not all properties will be shown in the property sheet—read-only ...

Get Developing Java Beans now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.