Solved

Java MouseReleased

Posted on 2000-02-29
1
881 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
1 Comment
 

Accepted Solution

by:
davidmorand earned 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

939 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now