Reputation: 7622
I have a JTable in a JScrollPane. When the user is at the top of the table, eg. row 0 is displayed and above it the table header tableHeader.contains(p);
is true
.
When the user scroll down and say row 10 is now the top row, if the mouse is over the table header and the table header changes its look due to that, tableHeader.contains(p);
is false
in all cases.
How can I detect that the mouse cursor is over the header when the top row is not row 0?
Upvotes: 0
Views: 417
Reputation: 263
Use
table.getTableHeader().addMouseListener(...)
to add a MouseListener to the table header. The MouseListener has a method
mouseEntered(MouseEvent e)
in which you can put the code you want to be executed when the cursor is over the table header.
Upvotes: 2