title: JTable mouse listener on row example
body: <p>I've taken this code from another question and was hoping someone could clarify a couple of points:</p>
  
  <pre><code>table.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseReleased(MouseEvent e) {
          int r = table.rowAtPoint(e.getPoint());
          if (r &gt;= 0 &amp;&amp; r &lt; table.getRowCount()) {
              table.setRowSelectionInterval(r, r);
          } else {
              table.clearSelection();
          }
  
          int rowindex = table.getSelectedRow();
          if (rowindex &lt; 0)
              return;
          if (e.isPopupTrigger() &amp;&amp; e.getComponent() instanceof JTable ) {
              JPopupMenu popup = createYourPopUp();
              popup.show(e.getComponent(), e.getX(), e.getY());
          }
      }
  });
  </code></pre>
  
  <p>i understand that the line that defines 'r' gets the row at the mouse event point. but why is 'rowindex' initialised using table.getSelectedRow()? why not just use the variable 'r'. aren't they the same thing?</p>
  
  <p>also - i'm confused by e.isPopupTrigger(). i read the documentation, and it refers to it as returning whether the mouseevent is the trigger for the popup.... the trick is obviously in the name - but i'm unsure of what conditions make it true or false (especially as popup.show(), whose first parameter is the invoker, is inside the if statement).</p>
  
  <p>sorry for the confusion, i just don't want to blindly copy the code!</p>
  
  <p>thanks</p>