August 23rd, 1999, 08:38 PM
hi all,
i would like to know how to select a table row with a right mouse click?
thanks,
anonymous.
i would like to know how to select a table row with a right mouse click?
thanks,
anonymous.
|
Click to See Complete Forum and Search --> : how does one select a JTable row when clicking the right mouse button? August 23rd, 1999, 08:38 PM hi all, i would like to know how to select a table row with a right mouse click? thanks, anonymous. JFM August 24th, 1999, 12:10 PM 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 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |