title: JTable right-click copy/paste menu to copy cell data on one click
body: <p>I created my <code>JPopupMenu</code>. It appears on my <code>JTable</code> when I right click on a cell. However, I cannot copy the data in the cell unless I first double click and then highlight the data, and then right click anywhere but this current cell to show my popup menu and copy option. </p>
  
  <p>I would like to copy the data in a cell without having to double click on a cell and enter into cell edit mode where I then need to select the data. </p>
  
  <p>How can I do this?</p>
  
  <pre><code>popup = new JPopupMenu();
  popup.setName("popupMenu");
  menuItemCopy = new JMenuItem(new DefaultEditorKit.CopyAction());
  menuItemCopy.setText("Copy");
  menuItemCopy.setName("copy");       
  popup.add(menuItemCopy);
  popup.addSeparator();
  menuItemPaste = new JMenuItem(new DefaultEditorKit.PasteAction());
  menuItemPaste.setText("Paste");
  menuItemPaste.setName("paste");
  popup.add(menuItemPaste);
  </code></pre>
  
  <p>Here's the code that I have in my <code>MouseListener</code> for my <code>JTable</code>, in <code>mouseReleased()</code> and <code>mousePressed()</code>.</p>
  
  <pre><code>if(e.isPopupTrigger())
  {
      JTable source = (JTable)e.getSource();
      int row = source.rowAtPoint( e.getPoint() );
      int column = source.columnAtPoint( e.getPoint() );
  
      gridView.popup.show(e.getComponent(), e.getX(), e.getY());              
  }
  </code></pre>