The Interaction Wizard allows you to quickly generate code for connecting interactions between components.
Once you are familiar with writing Java code to get and set component properties, or to create complex behaviors when an event occurs, you will probably usually use the Event page of the Component Inspector to specify a component event to handle, and then write the event handling code by hand.
Although that approach gives you the greatest flexibility in writing complex event handling code, in many cases a simple wizard approach is faster. This Interaction Wizard allows you to specify, by selecting from lists, simple actions that can be performed on components when an event occurs.
Another advantage of the Interaction Wizard is that it uses simple language to describe the interactions, whereas in the Inspector you must know the exact names for the events and properties, which are sometimes less than obvious until you get used to them.
An example of an event controlling the interactions between components interactions might be:
The way this example would work in this wizard is as follows:
This page of the wizard will be skipped (i.e. you will start on Step 2 of 4) if there is only one container class defined in the selected file.
The class selected on this page is the one into which code will be inserted by this wizard for creating the interactions between components.
To select the class, when there is more than one, simply click on it in the list box, then click the Next button.
Select which component will be generating the event to which you want to respond.
This page performs essentially the same role as selecting an event on the Events page of the Component Inspector. Going on to the next page is roughly equivalent to double clicking on the event in the Inspector to drill down into the event handling method where you can define what should happen when the event occurs. When using the Inspector, you would then have to type code by hand in the event handling method. Using this wizard, you can use the next two pages to define the action you want taken when this event occurs.
For our example above, in which pressing button1 should set the text of textField1 to "HelloWorld", you would select button1 here.
To edit the events displayed in this wizard, press the Edit Interactions button. This opens the Interaction Wizard Editor.
For our example above, in which pressing button1 should set the text of textField1 to "HelloWorld", you would select:
You might enter a literal string here if you are setting text. For our example above, in which pressing button1 should set the text of textField1 to "HelloWorld", you would enter "HelloWorld" here (without the quotes).
The required Java code will be inserted into the class selected in Step1.