The Essential JViews Framework > Getting Started with JViews Framework > Step 2 - View Interaction > Creating the Select Button

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