Setting component properties in the Inspector
Overview of the Inspector
The Component Inspector allows you to visually edit component properties and to attach code to component events.
With the Inspector, you can,
- Set the initial property values for components in the container, and for the container and its layout manager (initialization code).
- Create, name, and delete methods in the container that will receive events from the component in the container (event handling code).
Any changes you make in the Component Inspector are reflected immediately in the source code and in the UI Designer.
Opening the Inspector
To display the Component Inspector,
- Select a java file in the Navigation pane.
- Click the Design tab at the bottom of the AppBrowser.
The Inspector is displayed to the right of the AppBrowser which now is in Design mode.
Setting property values
Properties are attributes that define how a component appears and responds at run time. In JBuilder, you set a component's initial properties during design time, and your code can change those properties at run time.
The Properties page in the Inspector displays the properties of the selected component(s). This is where you set the property values at design-time for any component in your design. By setting properties at design time, you are defining the initial state of a component when the UI is instantiated at run time.
Note: To modify the initial property values at run time, you can put code in the body of the methods or event handlers which you can create on the Events page of the Inspector.
To set a component's properties at design time,
- Select a component in a designer (UI Designer or Menu Designer) or in the Component Tree.
- Click the Properties tab of the Inspector to give it focus.
- Scroll until the property you want is visible, then select it with the mouse or the arrow keys.
- Enter the value in the right column one of the following ways:
- When there is only a text field, you simply type the string value for that property, for example a text value or a number value, then press Enter.
- When the value field is displayed with a down arrow, click the down arrow and choose a value from the list, then press Enter. If there are only two values, for example true or false for a boolean property, when you select the arrow, the other value is automatically selected, however you must press Enter to commit the change.
- When the value field has an ellipsis button
, click it to display a property editor for that property, for example, a color or font selector. Set the values in the property editor, then press OK.
Important: To commit a modification in the Inspector to code, you must press Enter following a text entry or drop-down list selection, or click on a different property in the Inspector.
Setting shared properties for multiple components
When more than one component is selected, the Component Inspector displays only the properties they have in common that you can edit. When the value for the shared property differs among the selected components, the property value displayed is either the default or the value of the first component selected. When you change any of the shared properties in the Component Inspector, the property value changes to the new value in all the selected components.
To set properties for multiple components,
- Do one of the following to select the group of components to be changed:
- Hold down the Shift Key and select each of the components.
- Hold down the left mouse button and draw a "lasso" around the group of components you want to change.
- Select and edit the desired property in the Inspector.