title: Right Clicking on JButton
body: <p>trying to add a mouseAdapter to a JButton for a right click to flag the cell.  Problem is when I instantiate it onto the button, it won't let me.  Maybe because it already has an actionlistener on it?  I'm not too sure.  Any help is appreciated.  I'm creating a Minesweeper game, fyi.</p>
  
  <pre><code>button = new JButton[size][size];
  ButtonListener bl = new ButtonListener();
  for (int r = 0; r &lt; size; r++) {
  for (int c = 0; c &lt; size; c++) {
  button[r][c] = new JButton("");
  button[r][c].addActionListener(bl);
  button[r][c].addMouseListener (new MouseAdapter());``
  // error message: cannot instantiate the type MouseAdapter
  panel.add(button[r][c]);
  </code></pre>
  
  <p>eventually if that works, I want to incorporate this into the game:</p>
  
  <pre><code>button.addMouseListener(new MouseAdapter() { 
      public void mouseClicked(MouseEvent e) {
          if (e.getButton() == 3) { // if right click
              button.setText("F");
              button.getModel().setPressed(false);
              // button.setEnabled(true);
          } else {
              button.setText("X");
              button.getModel().setPressed(true);
              // button.setEnabled(false);
          }
      }
  });
  </code></pre>