Editing Bean Properties

The property sheet for a bean provides a way to display and set initial property values for the bean. Changes made to values in the property sheet are applied immediately.

You can edit the properties for a single bean or select several beans and open a property sheet for them. When you change a property on the property sheet, the change affects all the selected beans.

Some of the tasks you can perform include:

Opening the Property Sheet for a Bean

To change the properties for a single bean, follow these steps:

  1. From either the free-form surface or the Beans List window, place the pointer over the bean and double-click mouse button 1. The property sheet for the bean appears.
  2. When you have chosen the property you want to modify, select the value field to the right of the property name.
  3. Make the appropriate changes from the provided options. Options for modifying the properties depend upon the bean and may include selecting a button, entering information into the field, selecting from a drop-down list, or proceeding to other dialog boxes.

To change the properties for multiple beans (multiple selection), follow these steps:

  1. Select the beans with properties you want to change.
  2. Move the mouse pointer over one of the selected beans.
  3. Click mouse button 2.
  4. Select Properties from the pop-up menu. A property sheet for the selected beans appears and displays the common properties for the selected beans.

Once you open a property sheet, you can modify properties for most beans in the Visual Composition Editor. To open the properties on another bean select it in the Visual Composition Editor. To select if from within the property sheet:

  1. Open the drop-down list at the top of the property sheet.
  2. Select the bean you want to modify.
  3. Modify the properties.
Note:

If a common property is not visible on the property sheet, select the Show expert features check box.

To enable national language support for your composite, be sure to read Separating Strings for Translation.

Using Property Interface Editors

Some bean properties on the property sheet, such as border and model, use interface editors. If the property has an interface editor, a small button, Small Button which indicates a secondary window, appears to the right when youselect the value field for that property. When you select the Small Button , the interface editor for that property appears.

The interface editor provides two options: Code String and Bean Implementing Interface. To enter your own code string for the property, select Code String and type your code in the entry field. To see a list of available interfaces, select Bean Implementing Interface. From the drop-down list, select the desired interface for that property and modify any values listed.

Using Code Strings in Bean Properties

VisualAge enables you to set some bean properties using code strings. Curly braces, { }, in the value column of a bean property sheet indicate that you can type Java code directly into the property field.

For example, you can use code strings to dynamically instantiate a dialog window when the user selects a button.

  1. Create and save a dialog window named MyDialog.

  2. Create the main user interface bean and drop a factory bean with the type MyDialog.

  3. Connect the actionPerformed event of a button to the MyDialog method of the factory.

  4. Open the Event-to-Method Connection window and select the Set parameters button.

  5. Enter new java.awt.Frame() in the value field of the parent property.

    This string directs VisualAge to create a new instance of MyDialog when the button is selected.

  6. Connect the actionPerformed event of the button to the Show() method of the factory, to make the dialog visible.

Changing Bean Colors

Visual beans have color properties for the foreground and background. To change a color property of a bean in its property sheet, do the following:

  1. Select either the foreground or background property. A small selection button Prompt Button appears in the value column.
  2. Click the Prompt Button button to open the Colors property window.
  3. Select either the Basic, System, or RGB checkbox.

When you change bean colors, select colors that are available across various platforms.

For an example, open the background property in the property sheet for any of the com.ibm.ivj.examples shipped in the IBM Java Examples project.

Note:If you are setting the background property of a Swing bean, be sure the opaque property of the bean is set to true.

Changing Bean Fonts

To change the font of a bean in its property sheet, do the following:

  1. Select the font property. A small selection button Small Button appears in the value column.
  2. Click the Small Button button and the Fonts property window appears.
  3. Modify any of the following font values:
  4. Preview the font changes in the preview window.
  5. Click OK to apply the changes and return to the property sheet.

When you change bean fonts, select fonts that are available across various platforms.

For an example, open the font property in the property sheet for any com.ibm.ivj.examples.vc. class shipped in the IBM Java Examples project.

Changing Bean Size and Position

If a bean is embedded in a container that does not use a layout manager (null layout), you can change the x and y coordinates, the width, and the height using the bean property sheet. To modify the size and position features, do the following:

  1. Click the expansion icon Expansion Icon to the left of the constraints property.
  2. Select the value field for the property you want to modify and enter the new property value.
  3. Press enter to apply the value.
Note:If you specify a non-null layout for the container, the bean position and sizing constraints are affected by that layout manager.

When you open the bean property sheet using multiple selection, some size and position constraints may appear stippled rather than solid because the values for the field are not common to all the selected beans. Once you modify the constraint, however, all the selected beans have the same value and the constraint appears solid.

For an example of the different layout managers, see the COM.ibm.ivj.examples.vc.layoutmanagers.LayoutManagers class shipped in the IBM Java Examples project.

Adding Bean Icons

Some visual beans, such as JLabel and JButton, have icon properties. You can assign an icon to these beans through the property sheet.

To add an icon to a visual bean:

  1. Open the bean property sheet.
  2. Select the Icon value field.
  3. Select Small Button and the Icon Editor appears.
  4. To add an icon from a graphics file, select File and enter the fully qualified path and file name in the name field, or select Browse and select the file through the file locator.
  5. To add an icon from a URL, select URL and enter the fully qualified path and file name in the name field.
  6. Press Enter to view the icon in the preview pane.
  7. Select OK to accept the icon.

Editing Bean Labels

Some visual beans, such as buttons and menus, contain text strings. You can edit these labels through the property sheet.

To edit the text of a label:

  1. Open the bean property sheet.
  2. Select the label value field.
  3. Enter the new label name.


Related concepts
Visual Composition Editor Overview
Property Sheets

Related procedures
Manipulating Beans Visually

Related references
Visual Composition Editor
Pop-Up Menus for the Visual Composition Editor