Results 1 to 4 of 4
  1. #1
    nishant.4545 is offline Member
    Join Date
    Jul 2009
    Posts
    10
    Rep Power
    0

    Default Getting mouse coordinates

    I am writing a program wherein I need the coordinates of mouse pointer relative to screen. Using getX() and getY() method we get the x and y coordinates but that is relative to the current frame and to the screen. Is there any other method that returns the coordinates relative to screen? Plz help me

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Which GUI library are you using?

  3. #3
    nishant.4545 is offline Member
    Join Date
    Jul 2009
    Posts
    10
    Rep Power
    0

    Default

    I am using java swing for creating gui.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    If Swing, are you getting the x and y with a MouseListener or MouseMotionListener? Or with the Toolkit class? If the first two, then the MouseEvent object passed can get you the Point on screen via the getLocationOnScreen() method. Toolkit's MouseInfo object gets location information that is relative to the screen coordinates.

Similar Threads

  1. Resizing Coordinates In Applets
    By lolmasterzz in forum Java Applets
    Replies: 4
    Last Post: 07-12-2009, 04:17 AM
  2. button coordinates
    By jacline in forum AWT / Swing
    Replies: 2
    Last Post: 04-05-2009, 10:58 PM
  3. Java3D: Clicking and getting coordinates?
    By seabhcan in forum Advanced Java
    Replies: 0
    Last Post: 01-11-2008, 02:46 PM
  4. Object locations via grid coordinates HELP.
    By deadman_uk in forum New To Java
    Replies: 4
    Last Post: 11-18-2007, 08:32 PM
  5. Arc2D.Double coordinates
    By alley in forum Java 2D
    Replies: 2
    Last Post: 11-07-2007, 10:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •