This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Capture Mouse Events on JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "Capture Mouse Events on JTable" Watch "Capture Mouse Events on JTable" New topic
Author

Capture Mouse Events on JTable

samit naik
Greenhorn

Joined: Jul 31, 2001
Posts: 2
HI
How do i capture mouse events (such as mouse click) on a single cell in a JTable? Can i capture a mouse click if the cell is non-editable??
ciao
Rick Fortier
Ranch Hand

Joined: Jun 04, 2001
Posts: 147
I don't the answer but was curious as to why you would need it. On my design I just got the selected row when the user clicked on the Book Flight button.
int rowSelected = table.getSelectedRow()
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 2922
You can add a MouseListener and MouseMotionListener on the table to capture mouse clicks and mouse moves respectively. From the mouse event you'll get the coordinates and then you may call getRowAt(...) method of JTable to find which row the mouse event happened. Look up the API to see exact method name and parameters.
HTH,
Paul.
------------------
SCJP2 Resources, Free Question A Day, Mock Exam Results and More!
www.jdiscuss.com
Get Certified, Guaranteed!
www.enthuware.com/jqplus

Your guide to SCJD exam!
www.enthuware.com/jdevplus


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Capture Mouse Events on JTable
 
Similar Threads
JTable editing on mouse click
detect mouseclick of jtable if column renderer is also a jtable
How do i use hyperlinks in a JTable ?
Need help on JTable capturing EDITED data ..
JTable cell