Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Fetching mouse coordinates

Reply
Thread Tools

Fetching mouse coordinates

 
 
Kevin Pors
Guest
Posts: n/a
 
      09-01-2003
Is there any way how I can find the coordinates of the mouse on the screen in a static way?
All posts i've read mention the use of MouseListener and other interfaces which needs motion to determine
it. I'd like to find the absolute coordinates where the mouse currently is on the screen - NOT relatively of a
component.


 
Reply With Quote
 
 
 
 
Kevin Pors
Guest
Posts: n/a
 
      09-02-2003
On Mon, 1 Sep 2003 12:50:14 -0700, "William Brogden" <(E-Mail Removed)> wrote:

>
>"Kevin Pors" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed).. .
>> Is there any way how I can find the coordinates of the mouse on the screen

>in a static way?
>> All posts i've read mention the use of MouseListener and other interfaces

>which needs motion to determine
>> it. I'd like to find the absolute coordinates where the mouse currently is

>on the screen - NOT relatively of a
>> component.

>
>Isn't there a getLocationOnScreen method in the Component class?


Well it's more complicated than that. The situation is as follows:

JFrame, grandmother of the application. This frame hold a JToolBar.
On that toolbar I got my own created component, KButton. I want to create my
own style of tooltip which is gonna be visible when I hover over the KButton.

For creating a tooltip thing, I extended JWindow. I need to position that window about 5 pixels down
and 5 pixels to the right of the cursor.

I'd like to get the cursor position of the screen without iterating through all the parents. That
wouldn't be a very clear and vast object oriented manner of programming, IMHO.

Regards,

Kevin
 
Reply With Quote
 
 
 
 
Tim Tyler
Guest
Posts: n/a
 
      09-13-2003
Kevin Pors <(E-Mail Removed)> wrote:

: Is there any way how I can find the coordinates of the mouse on the
: screen in a static way? All posts i've read mention the use of
: MouseListener and other interfaces which needs motion to determine
: it. I'd like to find the absolute coordinates where the mouse currently
: is on the screen - NOT relatively of a component.

Java only lets apps know where the mouse is when it is over a Component.

To read the mouse co-ordinates - and be guaranteed a result - use JNI.
--
__________
|im |yler http://timtyler.org/ http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Tim Tyler
Guest
Posts: n/a
 
      09-13-2003
Kevin Pors <(E-Mail Removed)> wrote:
: On Mon, 1 Sep 2003 12:50:14 -0700, "William Brogden" <(E-Mail Removed)> wrote:

:>Isn't there a getLocationOnScreen method in the Component class?

: Well it's more complicated than that. The situation is as follows:

: JFrame, grandmother of the application. This frame hold a JToolBar.
: On that toolbar I got my own created component, KButton. I want to create my
: own style of tooltip which is gonna be visible when I hover over the KButton.

: For creating a tooltip thing, I extended JWindow. I need to position
: that window about 5 pixels down and 5 pixels to the right of the cursor.

: I'd like to get the cursor position of the screen without iterating
: through all the parents. That wouldn't be a very clear and vast object
: oriented manner of programming, IMHO.

Surely, the "getLocationOnScreen" method does the iteration for you.

There is no cause to be concerned about performance here.
--
__________
|im |yler http://timtyler.org/ (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
monitor mouse coordinates in real-time Jabba Laci Python 3 08-17-2011 03:20 PM
Heres a mouse theres a mouse what a mouse do? unholy Gaming 37 09-17-2006 08:59 AM
Firefox 1.5: Wrong mouse coordinates passed to the OnClick() event handler? Juergen Theis ASP .Net 0 02-21-2006 09:43 AM
Converting canvas coordinates to window coordinates in tkinter......... Suresh Kumar Python 0 07-04-2003 10:14 AM
Converting canvas coordinates to window coordinates....... Suresh Kumar Python 0 07-03-2003 04:53 AM



Advertisments