🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #13027

How to get screen location of cursor

#13027
From: mstam
Date: Thu, 08 Oct 1998 00:00
31 lines
1840 bytes
       You can retrieve the exact mouse location by using a combination
       of mouse events and the position of the component you are listening
       to.

       Example.


        Note: m_SourceComponent is the component generating the MouseEvents.
              p_MouseReleased is the MouseEvent.


        Point ptOfRelease = getReleaseCoords( p_MouseReleased );

        protected Point getReleaseCoords( MouseEvent p_MouseReleased )
        {
         Rectangle rectSource = m_SourceComponent.getBounds();
         Point     ptSource   = m_SourceComponent.getLocationOnScreen();

         Point     ptScreenCoords = new Point();

             ptScreenCoords.x  = p_MouseReleased.getX() - rectSource.width;
             ptScreenCoords.x += rectSource.width + ptSource.x;

             ptScreenCoords.y  = p_MouseReleased.getY() - rectSource.height;
             ptScreenCoords.y += rectSource.height + ptSource.y;

             return ptScreenCoords;
        }

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
Technical Details
Message-ID: <6vif3v$kct$1@nnrp1.dejanews.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6v1hld$2oc9@forums.borland.com> <MPG.107e870dc78d745b98991c@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,8c12370b73b7ec11
X-Google-Attributes: gid111d45,public
From: mstam@my-dejanews.com
Subject: How to get screen location of cursor
Date: 1998/10/08
Message-ID: <6vif3v$kct$1@nnrp1.dejanews.com>
X-Deja-AN: 398977383
References: <6v1hld$2oc9@forums.borland.com> <MPG.107e870dc78d745b98991c@forums.borland.com>
X-Http-Proxy: 1.1 x12.dejanews.com:80 (Squid/1.1.22) for client 12.11.151.152
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Thu Oct 08 13:35:57 1998 GMT
Newsgroups: borland.public.jbuilder.java.swing
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)