ToolTip for Graphical Items

B

bwilde

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
 
O

Oliver Wong

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
 
S

Steve W. Jackson

Oliver Wong said:
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 =
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top