• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trapping mouse movement

 
Fardeen Siddiqui
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
can someone please tell me how can i trap the x,y corordinates of the mouse move on an image
thanx
 
Noah Carroll
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can add a MouseMotionListener using a MouseMotionAdapter class. You can't add a listener to the image directly but to the applet or application in general. It will still work. Whenever the mouse is moved it calls the mouseMoved method. You can do whatever code is necessary in that method.
------------------
I hope its helps, feel free to email me noahcarroll@juno.com
 
Grant Crofton
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, it would go something like this:

you'd need to import java.awt.event.*
(I haven't checked that code, but I think it's right).
You need to watch this, because when the mose is moving in the canvas, mouseMoved events will get fired loads. However, if you want it to catch every single pixel, it probably won't be fast enough.
Grant.
 
Fardeen Siddiqui
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
hey thanx a lot its working now
Fardeen
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!