•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 397,845 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,429 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1876 | Replies: 2 | Solved
![]() |
Is there any function in MouseListener that returns the x- and/or y-coordinates of the cursor relative to the origin of a JPanel which currently has the focus? ¡Ayúdenme, por favor! Beware of the Rancor. I'm not kidding.
If it doesn't compile, try saying "By the power of MegaMan!!!" <this has kinda worked for me, actually...>
Scotland is NOT North Britain, Glasgow does NOT rhyme with "cow", and Robbie Burns is...well, if you don't already know who he was, you're kinda screwed.
If it doesn't compile, try saying "By the power of MegaMan!!!" <this has kinda worked for me, actually...>
Scotland is NOT North Britain, Glasgow does NOT rhyme with "cow", and Robbie Burns is...well, if you don't already know who he was, you're kinda screwed.
The MouseEvent getX() and getY() methods will return the coordinates relative to the source of the event. If your panel is not that source, you will have to compute the coordinates yourself by adding them to the coordinates of the source (which also has getX() and getY() methods) within that panel. It just depends on the layering of your components and which is the source of the mouse event. This tutorial has more info if you need it:
http://java.sun.com/docs/books/tutor...nlistener.html
http://java.sun.com/docs/books/tutor...nlistener.html
Thank you, Ezzaral. Helpful, concise, and 1337; just how the best answers are. Party on, dude.
Beware of the Rancor. I'm not kidding.
If it doesn't compile, try saying "By the power of MegaMan!!!" <this has kinda worked for me, actually...>
Scotland is NOT North Britain, Glasgow does NOT rhyme with "cow", and Robbie Burns is...well, if you don't already know who he was, you're kinda screwed.
If it doesn't compile, try saying "By the power of MegaMan!!!" <this has kinda worked for me, actually...>
Scotland is NOT North Britain, Glasgow does NOT rhyme with "cow", and Robbie Burns is...well, if you don't already know who he was, you're kinda screwed.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
- How can I get Mouse Position? (VB.NET)
- Simulate Mouse Move (C++)
- negative coordinates? (C)
- Move Mouse in C++ (C++)
- win32 api mouse coordinates weird (C)
- Making a Java Key Logger (Java)
- hover over text tips (JavaScript / DHTML / AJAX)
- looking for a script for menubar (JavaScript / DHTML / AJAX)
- plotting graphs (Java)
- manipulating graphs in a GUI (Java)
Other Threads in the Java Forum
- Previous Thread: convert string to double, and result is string again
- Next Thread: Need Help, Getting Exceptions



Linear Mode