Here you can find the source of rowAtPoint(MouseEvent mouseEvent)
mouseEvent
occurred over a JTable , retrieve the row over which the event occurred.
Parameter | Description |
---|---|
mouseEvent | a MouseEvent whose source is a JTable |
static int rowAtPoint(MouseEvent mouseEvent)
//package com.java2s; //License from project: Open Source License import java.awt.Point; import java.awt.event.MouseEvent; import javax.swing.JTable; public class Main { /**//from w ww.j a v a 2 s . c om * Assuming the <code>mouseEvent</code> occurred over a {@link JTable}, * retrieve the row over which the event occurred. * * @param mouseEvent a MouseEvent whose source is a {@link JTable} * @return the index of the table row over which the event occurred */ static int rowAtPoint(MouseEvent mouseEvent) { final JTable table = (JTable) mouseEvent.getSource(); final Point clickPoint = mouseEvent.getPoint(); return table.rowAtPoint(clickPoint); } }