Setting Events With the Connection Wizard
See Also
You can use the Connection wizard to set events between two components within
a form without having to write code manually.
To set and event using the Connection wizard:
- Click the Connection Mode button (
)
in the GUI Builder toolbar.
- In the GUI Builder or Inspector window, select the component
that will fire the event. Notice that the selected component is highlighted
in red when selected.
- Select the component whose state you want to affect with the event.
- On the Connection wizard's Select Source Event page, select the event that
the trigger component will fire from the Events list by expanding the event type directory nodes.
Accept the default handler method name or type in a new name and click Next.
- On the Specify Target Operation page, specify the operation to be performed
on the target component by selecting the appropriate radio button and choosing
from the list of operations. Click Next. Notice that if you chose
a method call with no parameters, the Finish button of the wizard becomes
available.
- (Optional) If you wish to enter event handler code directly, choose the
User Code radio button and click Finish. The insertion point is placed in
the new event handler in the Source Editor, where you can write the event
handler code yourself.
- On the Enter Parameters page, specify the values for each tab's target property
or method by selecting the source from which each parameter's value is acquired.
You can choose to get the parameter from any of the following:
- Value. Enter the property value or method parameter into
the text field. This option is available only if the value is a primitive
type (int, float, and so on) or a String.
- Bean. Acquire the value from a bean on the form. This
option is available only if there are beans of the specified type to
choose from (for example, type Component or Object).
- Property. Acquire the value from a property of a component
on the form. Click the ellipsis (...) button to display a dialog box
from which you can select the component and its property. Only properties
of the correct type are listed.
- Method Call. Acquire the value from a method call of
a component on the form. Click the ellipsis (...) button to display a
dialog box from which you can select the component and its method. Only
methods that return the correct type and that do not take any parameters
are listed.
- User Code. Write your own code to acquire the property
or method parameter value.
The source code generated for each of the parameters is displayed in
the Generated Parameters Preview field.
- Click Finish.
The IDE automatically generates the code to connect the form's components.
- See Also
- Managing Component Events
- Designing Java GUIs with the GUI Builder
- About Java GUIs
Legal Notices