|
-
August 23rd, 1999, 08:38 PM
#1
how does one select a JTable row when clicking the right mouse button?
hi all,
i would like to know how to select a table row with a right mouse click?
thanks,
anonymous.
-
August 24th, 1999, 12:10 PM
#2
Re: how does one select a JTable row when clicking the right mouse button?
table.addMouseListener(new TableMouseListener());
...
class TableMouseListener extends MouseAdapter {
public void mousePressed(MouseEvent e) {
JTable table = (JTable)(e.getSource());
Point p = e.getPoint();
int row = table.rowAtPoint(p);
int col = table.columnAtPoint(p);
// The autoscroller can generate drag events outside the Table's range.
if ((col == -1) || (row == -1)) {
return;
}
if (SwingUtilities.isRightMouseButton(e)) {
//for example, do this
table.setRowSelectionInterval(row, row);
}
}
}
-JFM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|