Created
November 8, 2012 12:50
-
-
Save biswarupadhikari/4038614 to your computer and use it in GitHub Desktop.
How to Detect Right Click Linux Java JTable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jt.addMouseListener(new MouseAdapter() { | |
public void mouseReleased(MouseEvent e) { | |
int r = jt.rowAtPoint(e.getPoint()); | |
if (r >= 0 && r < jt.getRowCount()) { | |
jt.setRowSelectionInterval(r, r); | |
} else { | |
jt.clearSelection(); | |
} | |
int rowindex = jt.getSelectedRow(); | |
JPopupMenu popup = mypopupmnu(); | |
if (rowindex < 0) | |
return; | |
if (e.isPopupTrigger() || SwingUtilities.isRightMouseButton(e)) { | |
// JPopupMenu popup = mypopupmnu(); | |
popup.show(e.getComponent(), e.getX(), e.getY()); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment