View Single Post
  #1 (permalink)   [ ]
Old 05-02-2009, 03:33 AM
The Readeemer The Readeemer is offline
Zora Warrior
Join Date: Feb 2009
Location: Oh...
View Posts: 268
Java Programming - how to implement a Mouse Listener effectively?

Okay, so I'm just wondering how to implement a MouseListener on a class that I'm writing. Pretty much, I have some class, say SimpleCanvas, a stripped down version of Canvas.java

This SimpleCanvas has a method called "addMouseListener (MouseListener ml)"

I've told another class which is calling SimpleCanvas to implement MouseListener; my question is:

How do the MouseEvents work? If SimpleCanvas is defined in a Cartesian-like co-ordinate system, and I want the MouseClicked (MouseEvent e) to work by checking where the mouse was clicked, relative to SimpleCanvas' co-ordinate system, how would I do so? e.getX() and e.getY()? Or something else?

Sorry if this sounds kinda stupid. I suck at programming.

Cheers
~read~
__________________
Dansa med oss! Klappa era händer! Gör som vi gör Ta några steg åt vänster! Lyssna och lär Missa inte chansen Nu är vi här med

Caramelldansen!
Reply With Quote