Solved

Java MouseReleased

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet example issue 6 40
login jsp example 24 50
Desingning Refactoring existing code 2 24
JAVA API design with micro service cloud in mind 1 18
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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.

777 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