Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to detect single click on any cell of JTable ?

 
Mahajan Bhupendra
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i m using JTable in my application
i want to detect a mouse click on any cell with cell row and
col number..
how should i do that because JTable is having only TableEventListener which detects only change in table cell..
Bhupendra Mahajan
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your mouse event code put in this:
Point pnt = evt.getPoint();
int row = table.rowAtPoint(pnt);
int col = table.columnAtPoint(pnt);

That will give you the row and column.
 
Mahajan Bhupendra
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankx paul
It works...
How u have so much knowledge and i don't??
Bhupendra Mahajan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic