The following code creates a Select button and associates
it with the selectInteractor
:
void createButtons()
{
JButton button;
button = new JButton("Select");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (selectInteractor == null)
selectInteractor = new IlvSelectInteractor();
if (mgrview.getInteractor() != selectInteractor)
mgrview.setInteractor(selectInteractor);
}
});
getContentPane().add(button, BorderLayout.SOUTH);
}
When you click the Select button, the
actionPerformed
method first creates its interactor (if this has not already been
done), then it installs the interactor on this view using the
setInteractor method. Once the interactor is installed, you can
select, move, and modify the graphics objects displayed in the view.