?
Solved

Java MouseReleased

Posted on 2000-02-29
1
Medium Priority
?
898 Views
Last Modified: 2012-06-21
When i release the mouse and get the co-ordinates of where the mouse has being released, e.getX(), e.getY(). it tells me that the position of my cursor is at aroung the top left hand corner of my screen, when in fact it is in the middle of the screen and no where near the co-ordinates it tells me its at, how can i solve this problem of the getting wrong position of my cursor, or any ideas as to what is making it hapen like this??
0
Comment
Question by:j_baxter99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
davidmorand earned 150 total points
ID: 2569137
The x and y position you get are from the component where you handle the mouseReleased event.

So if you handle it on a button and you click on the upper left corner of the button you will get (0,0).

You need to translate those coordinates to screen coordinates using the position of your component as you reference.

so if you have a JWindow at position (100,100) in the screen and you release the mouse at position (50,50) in the JWindow then your cursor is at (150, 150) in the screen!
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question