Using the Inspector

Overview of the Inspector

The Inspector lets you visually edit component properties and attach code to component events.

Inspector

Using the Inspector, you can

Any changes you make in the Inspector are reflected immediately in the source code and in the UI designer.

Opening the Inspector

To display the Inspector,
  1. Double-click a Java file in the project pane.
  2. Select the Design tab at the bottom of the AppBrowser.
The Inspector is displayed at the right of the content pane which is now in design view.

Resize the Inspector by dragging the left border right or left with the mouse. To adjust the width of the Inspector's columns, drag the column divider in the border at the top of the Inspector to the right or left


Setting property values

Properties are attributes that define how a component appears and responds at runtime. In JBuilder, you set a component's initial properties during design time, and your code can change those properties at runtime.

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 runtime.

Note: To modify the initial property values at runtime, 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,

  1. Select a component in a designer (UI designer or menu designer) or in the component tree.
  2. Click the Properties tab of the Inspector.
  3. Select the property you want to change using the mouse or arrow keys. You may need to scroll down until the property you want is visible.
  4. Enter the value in the right column in one of the following ways:

Setting shared properties for multiple components

When more than one component is selected, the 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 Inspector, the property value changes to the new value in all the selected components.

To set properties for multiple components,

  1. Do one of the following to select the group of components to be changed:
  2. Select and edit the desired property in the Inspector.

Setting a property when the drop-down list is empty

Sometimes, when you try to set a property in the Inspector (such as Swing models), all you see in the value's drop-down list is <none>.

When no property editor is specified for a property in the bean's BeanInfo class (or if the bean does not have a BeanInfo class), the Inspector uses a default editor based on the property value's data type. If a property takes a String, for example, the editor for that property lets you type in your string.

The list of property editors by type is stored in propertyEditors.properties in the .jbuilder folder. If no default editor is registered for a particular data type, JBuilder builds a drop-down list containing all objects of the correct data type that are in scope (objects that have instances in the object you are designing). If there are no objects of the correct data type in scope, then the drop-down list will be empty.

For example, a JTable has a model property that takes objects of type TableModel. If you add a JTable to your design in the UI designer, then click the drop-down arrow on its model property in the Inspector, the drop-down list value is <none>.

drop down

Note: To make the model property visible in the Inspector, right-click in the Inspector and choose Property Exposure Level|Hidden.

To populate the model property drop-down list in the Inspector, add objects of type TableModel to your class.

In this case, you can add a TableModel class from the javax.swing.table package to the design from the component palette as explained in the following steps.

Adding or Removing String values from ResourceBundle files

This is a feature of JBuilder Professional and Enterprise.
You can use the Inspector to remove a property's String value from a ResourceBundle file after you've resourced your project, or you can add a String value to a new or existing ResourceBundle file.

Right-click a property that takes a String value and choose ResourceBundle. The Localizable Property Setting dialog appears.

Resource Bundle

Important: If you remove a resourced component from the UI, it is not automatically removed from its resource file, in case the key is used somewhere else in your code. You must open the resource file and manually remove the entry.

For information on resourcing and international enablement, see Developing International Programs and the Resource wizard.

Setting the Property Exposure Level

You can choose what level of properties are exposed for the component in the Inspector based on how the properties are marked in the BeanInfo class for the component. Right-click in the Inspector and choose Property Exposure Level to display a pop-up menu with three choices:

property exposure

Regular
The Inspector displays only the properties that are not marked "Hidden" or "Expert" in the component's BeanInfo class.
Hidden
The Inspector displays only the properties marked "Hidden" in the component's BeanInfo class.
Expert
The Inspector displays the properties marked "Expert" in the component's BeanInfo class, plus everything displayed in "Regular".

Note: Properties not exposed in the BeanInfo Class remain hidden. The designer does not know about them unless a property setting for one was found in the JbInit() method, in which case they appear in the Inspector.

Exposing a property as a class level variable

You can use the Inspector to expose a property as a class level variable so you can set properties and events for it. For example, the jTextArea component has a document property that has a value of <none>. To expose it as a class level variable, right-click the document property and choose Expose As Class Level Variable. A variable called document1 is added to the list of class variables in the source code and the document property now shows a value of document1.

JBuilder also adds document1 to the Other folder in the component tree and exposes its properties and events in the Inspector. Now you can select document1 and create event handlers for it from the Events tab.