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 / GUI / August 2005

Tip: Looking for answers? Try searching our database.

Picking with java 2D ?

Thread view: 
Carsten Zerbst - 16 Aug 2005 16:12 GMT
Hello,

I just wrote a simple Java 2D based component to display
geometrical entities. On some off them I want to display a tooltip.
In the Tcl/Tk canvas I would bind the mouse enter event for the
items, but what is the prefered solution in Java 2D ?

My current solution is based on the bounding boxes of the GeneralPath,
but does not work that smooth. As the items are pretty small,
an offset is needed to enable picking.
But the bounding box + offset does not work, as the bounding box of the
interesiting items may overlap.

Any tips appreciated, Carsten
Tomba - 22 Aug 2005 10:43 GMT
> Hello,
>
[quoted text clipped - 10 lines]
>
> Any tips appreciated, Carsten

I have kind of the same problem. I must draw several splines and
rectangles in a canvas, but then every item must be clickable.
I would like any tips how I should check whether a mouse click selects a
drawn item or just doesn't need any action...

thanks in advance - too ;)
Thomas Hawtin - 22 Aug 2005 13:24 GMT
> Hello,
>
[quoted text clipped - 8 lines]
> But the bounding box + offset does not work, as the bounding box of the
> interesiting items may overlap.

I suggest overriding JComponent.getToolTipText(MouseEvent). Use
Shape.contains (GeneralPath implements Shape) to find which object to pick.

If you are using separate components for each shape (which may not be
particularly efficient), then override JComponent.contains instead.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/



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.