Solved

Java MouseReleased

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
table example 4 32
ejb example issues 3 26
String array comparison 4 38
jsp CRUD operations with and without prepared statement also hibernatge 1 11
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 last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

828 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