> 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