> How can I execute an action (or function) when the user will click
> into the JPanel ???
You need to make a class that implements MouseListener. There are a
bunch of different mouse events - I forget them all off the top of my
head - so see the Javadocs. But a MouseListener is what you want. Or if
a click is all you're interested in, extend MouseAdapter.
Hope this helps..
Joe
cyprian - 25 May 2007 10:20 GMT
> leonardo.mcarre...@gmail.com wrote:
> > How can I execute an action (or function) when the user will click
[quoted text clipped - 8 lines]
>
> Joe
The getLocationOnScreen() method of the MouseEvent class that returns
a Point object is what you need. It gives the x,y coordinates,
absolute coordinates, of mouse event. If you want a position relative
to the container itself, that is the JPanel, then you might be
thinking of getMousePosition() of the component class that returns a
point relative to the position of the component.
I believe you know how to extend the mouseadapter or implement the
various mouselisteners.