Java Swing Mouse rowAtPoint(MouseEvent mouseEvent)

Here you can find the source of rowAtPoint(MouseEvent mouseEvent)

Description

Assuming the mouseEvent occurred over a JTable , retrieve the row over which the event occurred.

License

Open Source License

Parameter

Parameter Description
mouseEvent a MouseEvent whose source is a JTable

Return

the index of the table row over which the event occurred

Declaration

static int rowAtPoint(MouseEvent mouseEvent) 

Method Source Code

//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);
    }
}

Related

  1. removeMouseListenerToHierarchy(JComponent c, MouseListener listener)
  2. removePopup(JComponent mouseEvtComp)
  3. retargetMouseEvent(int id, MouseEvent e, Component target)
  4. retargetMouseEvent(int id, MouseEvent e, Component target)
  5. retargetMouseEvent(MouseEvent e, Component target)
  6. setHintOnMouseHover(JComponent view, String tooltip, JLabel onView)
  7. shouldIgnore(MouseEvent me, JComponent c)
  8. swingDispatch(MouseEvent e, Component component)