Question

I have a JTable with a set of uneditable cells and I want all the cells in a particular column to have a different mouse cursor displayed whilst the mouse is hovering over them. I am already using a custom renderer and setting the cursor on the renderer component doesn't seem to work (as it does for tooltips).

It does seem to work for editors.

Is this not possible in JTable when your cell is not being edited or am I missing something?

Was it helpful?

Solution

Add a MouseMotionListener to the JTable and then on mouseMoved() determine which column it is using JTable's columnAtPoint() and if it's the particular column you are after, setCursor() on the JTable.

OTHER TIPS

Here is one way of changing the cursor at a particular column in JTable:

if(tblExamHistoryAll.columnAtPoint(evt.getPoint())==5)
{
    setCursor(Cursor.HAND_CURSOR); 
}
else
{
    setCursor(0);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top