Using the Connection Wizard
The Connection Wizard enables you to set events between two components without having to write much (or any) code by hand. When you choose two components to be "connected", the first is the one that will fire the event, and the second one will have its state affected by the event.
To start the Connection Wizard:
- Switch to connection mode on the Component Palette (see Connection mode).
![]()
- Next, click on the two components (first the component with the source event and then the target component). You can click on the form--or click in the Component Inspector (which enables you to also use non-visual components as parts of the connection).
The Connection Wizard opens to connect the chosen components.
The Connection Wizard enables you to set the connection parameters in two or three steps:
Connection Source
The first step enables you to choose the event of the source component on which the operation is to be performed and the name of the event handler method generated.
![]()
Note: If you choose an event that already has an event handler attached (the name of the event handler is visible in the tree of events after the event name - like
actionPerformed [button1ActionPerformed]
), when clicking Next, you will be asked if you want to delete the old event handler. If you answer yes, the old event handler is replaced with the connection code when the Connection Wizard is finished.Connection target
The second step enables you to specify the operation that is to be performed on the target component. There are four options which can be changed using the radio buttons along the top of the dialog box:
- Set Property - enables you to set a property on the target component. In the next step you specify the property value.
- Method Call - enables you to call a method on the target component. In the next step you specify the parameters for the method call.
- User Code - enables you to write the code by hand. When you choose this option, the Next> button changes to Finish, meaning there are no settings remaining in the wizard and the target component is ignored by the wizard. The insertion point in the editor is then placed into the new event handler enable you to write the handling code by hand.
![]()
Choosing property value or method parameters
If you have chosen Set Property, Method Call, or Bean in the previous step, the third step will enable you to specify the values for the target property or parameters for calling the target method. If you have chosen Method Call, the dialog box will display a list of all parameters types as tabs, where each tab represents a single method parameter.
On each tab, you can set the source from which the value (of the specified type) is acquired:
- Value - This option is available only if the value is a primitive type (
int
,float
, and so on) or aString
. You can enter the value into the text field.- Bean - This option enables you to acquire the value from a bean on the form. If you click on the ... button, a dialog box will appear which will let you choose the bean.
- Property - This option enables you to acquire the value from a property of a component on the form. If you click on the ... button, a dialog box will appear which will let you choose the component and its property. Note that only properties of the correct type are listed.
- Method - This option enables you to acquire the value from a method call of a component on the form. If you click on the ... button, a dialog box will appear which will let you choose the component and its method. Note that only methods which return the correct type and which do not take any parameters are listed.
- User Code - This option enables you to write user code which is used as the parameter for the setter of the chosen property or a parameter of the chosen method call.
![]()
If you click Finish, a new event handler will be generated with code reflecting the settings entered in the second and third step.
Contents | Prev | Next | Index |