Swing JTable right-mouse selection & popup menus 
When requesting the popup menu on a table with no current selection it is sometimes convenient to have the table select the clicked row before poping up the menu.
This can be achieved using the following code:
table.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.getModifiers() == Event.META_MASK
&& getSelectedRowCount() == 0) {
Point p = e.getPoint();
int row = table.rowAtPoint(p);
table.setRowSelectionInterval(row, row);
}
}
});