Skip to main content

Need a way to get information about the location of the mouse

No replies
Anonymous

Hello.

When using CSH you'll get an AWTEvent (normally a MouseEvent) in the
CSH.Manager class you can use to determine which Component was clicked.

I used this to generate a hierarchical string representing that component
(e.g. JFrame->JInternalFrame->JLabel). The MouseEvent delivers me the
deepest component (e.g. JLabel) of which I can call getParent().

This works well excepting JTables. When clicking on a cell, I will get
DefaultTableCellRenderer. Calling getParent() will delivers me null, as a
Renderer is just needed to draw the cell, it is not integrated in the
Component hierarchy.

One possible way is to use the location on screen to determine which JTable
is clicked. But the same here, getLocationOnScreen delivers null.

A possible solution would be to get information about the global mouse
location through the CSH class. Here the last mouse motion event can be
stored and the location could be accessed through a getMouseLocation()
method. You will just have to alter the private getMouseEvent() method
(that's exactly the problem: most of the methods in the CSH class are
private).

Perhaps somebody can tell me a workaround. If not, I will post a bugreport
on that.

Regards,
JOERN_HEID

********************************************************************************

You may leave the list at any time by sending message with no subject and
"SIGNOFF JAVAHELP-INTEREST" in the body to LISTSERV@JAVA.SUN.COM. Archives
are available at http://archives.java.sun.com/archives/javahelp-interest.html.
Submit bug reports at http://java.sun.com/cgi-bin/bugreport.cgi.