I have a JTable with some columns and rows. My idea was to detect mouse movement inside table and highlight rows that the mouse is pointing at. Though I want any highlight to disappear when the mouse is outside table which does not happen. I have some code in "if" statement but it doesn't work.
How can I do that?
table.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
if (e.getPoint().x == 0 || e.getPoint().y == 0) {
table.clearSelection();
}
table.changeSelection(table.rowAtPoint(p), table.columnAtPoint(p), false, false);
}
});