Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

How get click position on JPanel?

Thread view: 
leonardo.mcarreiro@gmail.com - 22 May 2007 21:42 GMT
How can I execute an action (or function) when the user will click
into the JPanel ???
Any examples may help-me...

tanks
Joe Attardi - 22 May 2007 21:44 GMT
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.