ToolTip for Graphical Items  
Author Message
bwilde





PostPosted: 2006-4-22 1:42:00 Top

java-programmer, ToolTip for Graphical Items Hello,

I'm trying to make a tool tip pop up whenever the user does a
mouse-over on a filled rectangle that I've drawn on the screen. I have
no trouble creating the rectangle

Rectangle test = new Rectangle();

And it seems like there should be something like
test.setToolTipText("rectangle"), but as far as I can tell, there's
nothing like that. Is there some way to do this?

Thanks,
Ben

 
Oliver Wong





PostPosted: 2006-4-22 3:26:00 Top

java-programmer >> ToolTip for Graphical Items
<email***@***.com> wrote in message
news:email***@***.com...
> Hello,
>
> I'm trying to make a tool tip pop up whenever the user does a
> mouse-over on a filled rectangle that I've drawn on the screen. I have
> no trouble creating the rectangle
>
> Rectangle test = new Rectangle();
>
> And it seems like there should be something like
> test.setToolTipText("rectangle"), but as far as I can tell, there's
> nothing like that. Is there some way to do this?

See
http://java.sun.com/docs/books/tutorial/uiswing/components/tooltip.html

There's a part that says:

<quote>
Multi-part components such as JTabbedPane, JTable, and JTree override [the
String getToolTipText(MouseEvent)] method to return a string associated with
the mouse event location. For example, each tab in a tabbed pane can have
different tool-tip text.
</quote>

- Oliver

 
Steve W. Jackson





PostPosted: 2006-4-22 4:03:00 Top

java-programmer >> ToolTip for Graphical Items In article <Nka2g.1039$8E1.920@clgrps13>,
"Oliver Wong" <email***@***.com> wrote:

> <email***@***.com> wrote in message
> news:email***@***.com...
> > Hello,
> >
> > I'm trying to make a tool tip pop up whenever the user does a
> > mouse-over on a filled rectangle that I've drawn on the screen. I have
> > no trouble creating the rectangle
> >
> > Rectangle test = new Rectangle();
> >
> > And it seems like there should be something like
> > test.setToolTipText("rectangle"), but as far as I can tell, there's
> > nothing like that. Is there some way to do this?
>
> See
> http://java.sun.com/docs/books/tutorial/uiswing/components/tooltip.html
>
> There's a part that says:
>
> <quote>
> Multi-part components such as JTabbedPane, JTable, and JTree override [the
> String getToolTipText(MouseEvent)] method to return a string associated with
> the mouse event location. For example, each tab in a tabbed pane can have
> different tool-tip text.
> </quote>
>
> - Oliver

A Rectangle is nothing more than a class built around the x and y
coordinate of its upper left corner, and its width and height. It's
just a mathematical representation. A tooltip is displayed in response
to something happening between a mouse and a Swing component, such as a
JPanel or those listed above or others. So in order for a Rectangle to
have a tooltip, a graphical representation of it needs to appear on some
component and a tooltip needs to be assigned to that component (or the
appropriate area of it).

= Steve =
--
Steve W. Jackson
Montgomery, Alabama