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 / January 2006

Tip: Looking for answers? Try searching our database.

Minimalist tooltip

Thread view: 
Rob McDonald - 13 Jan 2006 03:44 GMT
I would like to have tooltips pop up when the user hovers over a
Rectangle2D.  From what I can tell, JToolTips are meant to be attached
to a JComponent.  I'd rather not make every 'hot box' a superclass of
JComponent.

Whats the best way to go about doing this?

Thanks for any suggestions,

       Rob
Thomas Weidenfeller - 13 Jan 2006 08:22 GMT
> I would like to have tooltips pop up when the user hovers over a
> Rectangle2D.  From what I can tell, JToolTips are meant to be attached
> to a JComponent.  I'd rather not make every 'hot box' a superclass of
> JComponent.

But your Rectangle2D is for sure painted on a JComponent of some kind?
Override the component's getTooltipText(MouseEvent) and provide
different texts. This of course requires you have a suitable (not to
slow) way of mapping coordinates to your rectangles.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Rob McDonald - 13 Jan 2006 14:54 GMT
> But your Rectangle2D is for sure painted on a JComponent of some kind?
> Override the component's getTooltipText(MouseEvent) and provide
> different texts. This of course requires you have a suitable (not to
> slow) way of mapping coordinates to your rectangles.

I'm sorry, but that was far too easy.  Could you please come up with a more
difficult approach?  (:

Actually, it took me a while to realize that I needed to override
getToolTipText() not getTooltipText().  And then, you still have to 'turn
on' the tool tip with JComponent.setToolTipText("blah");  Even though you
don't care about "blah" otherwise, the listeners aren't set up.

Thanks a bunch,

            Rob


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.