File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to detect single click on any cell of JTable ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to detect single click on any cell of JTable ?" Watch "How to detect single click on any cell of JTable ?" New topic
Author

How to detect single click on any cell of JTable ?

Mahajan Bhupendra
Ranch Hand

Joined: Dec 01, 2000
Posts: 118
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


<B>Bhupendra Mahajan</B>
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
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

Joined: Dec 01, 2000
Posts: 118
Thankx paul
It works...
How u have so much knowledge and i don't??
Bhupendra Mahajan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to detect single click on any cell of JTable ?