• Post Reply Bookmark Topic Watch Topic
  • New Topic

to change cursor symbol in JTable cells  RSS feed

 
kumar m
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a problem, how to change the cursor when moving from one cell to another cell in a JTable.
For example: In my application, for a single column the cursor type should be Hand-Cursor. When I exit from that column it should change to Default cursor.
Bit of code is given below: I have used mouselistener events
public void mouseExited(MouseEvent mouseevent)
{
int columnIndex = issueTable.columnAtPoint (mouseevent.getPoint());

int rowIndex = issueTable.rowAtPoint(mouseevent.getPoint());

if(columnIndex <= 10)
{
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
if(rowIndex == -1 || columnIndex == -1)
{
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}

public void mouseEntered(MouseEvent mouseevent)
{
int columnIndex = issueTable.columnAtPoint(mouseevent.getPoint());

int rowIndex = issueTable.rowAtPoint(mouseevent.getPoint());

if(columnIndex == 11)
{
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
else
{
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
But the problem is when i move from cell to cell in a row the cursor symbol is not changing. Only when I move out of table and gets in I can see the cursor symbol change.
Can anyone correct my code or give an alternate solution for this problem. Please help me with a sample code.
Thank you,
Regards
kumar
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!