Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting mouse location without a listener

In some situations I need to place a JFrame right where the mouse cursor is located. Do I really need a mouse listener to track mouse move events, or I can just read current mouse position somehow?

like image 623
milan Avatar asked Mar 04 '11 11:03

milan


People also ask

How do I find the location of my mouse?

In Mouse Properties, on the Pointer Options tab, at the bottom, select Show location of pointer when I press the CTRL key, and then select OK. To see it in action, press CTRL.

What method do you use to get the mouse point position for a mouse event?

getLocation() might be helpful. It returns a Point object corresponding to current mouse position. getPointerInfo(). getLocation() returns the position relative to the screen.

How do I get my mouse position in Qt?

Mouse move events will occur only when a mouse button is pressed down, unless mouse tracking has been enabled with QWidget::setMouseTracking(). Qt automatically grabs the mouse when a mouse button is pressed inside a widget; the widget will continue to receive mouse events until the last mouse button is released.


1 Answers

this could help:

MouseInfo.getPointerInfo().getLocation()

like image 109
oliholz Avatar answered Oct 15 '22 08:10

oliholz