ToolTips

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ToolTips

Jon Harman
Hi,

I wonder if Java has "tooltip" sort of functionality that shows a text
string whenever the pointer is over a button.  I have a plugin that puts
a panel beneath an image and I would like to give some help for the
buttons.  I notice that ImageJ does this via the status line, but I
can't find where this is implemented in the code.  The status line
solution is not the best, but I would give it a try if it is not too big
of a hassle.

Jon
Reply | Threaded
Open this post in threaded view
|

Re: ToolTips

Albert Cardona
For JButton:

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComponent.html#setToolTipText(java.lang.String)

Notice that it's the abstract class JComponent the one implementing the
tool tips, so you can add them to any of its subclasses (including JButton).

The "tool tip" in ImageJ shows in the status bar because neither are the
Tools in a button (but as a painted area in a Panel), nor do
java.awt.Button have tooltips (that I know of).

Remember google is much faster than the mailing list.

Albert
Reply | Threaded
Open this post in threaded view
|

Re: ToolTips

Jon Harman
Hi Albert,

Thanks for the info.  My plugin uses java.awt.Button.  I built it
originally using the Panel_Window example.  Is it possible to use
JButtons in my panel without much effort?  The differences between all
the Java interface components are extremely arcane to someone like me
who is not a Java expert .  Not something that I really want to spend my
time understanding either.  Of course it is unfair to expect others to
do the work of understanding this and I appreciate the efforts by
experts like you to help.

Jon

Albert Cardona wrote:

> For JButton:
>
> http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComponent.html#setToolTipText(java.lang.String)
>
>
> Notice that it's the abstract class JComponent the one implementing
> the tool tips, so you can add them to any of its subclasses (including
> JButton).
>
> The "tool tip" in ImageJ shows in the status bar because neither are
> the Tools in a button (but as a painted area in a Panel), nor do
> java.awt.Button have tooltips (that I know of).
>
> Remember google is much faster than the mailing list.
>
> Albert
>
Reply | Threaded
Open this post in threaded view
|

Re: ToolTips

Jim Cant
Sure, just change 'Buttonn' to 'JButton' and your done.

I'd suggest refering frequently to the JavaDocs for the Java API.  For example, if you look at JButton you will see that it inherits from JComponent 'setToolTipText()' and you're on your way.

The JavaDoc often contains links that are _real_ helpful; clicking on the setTooTipText link not only describes that function but has this link: "see How to Use Tool Tips  in The Java Tutorial".

Also, as another said, searching in Google or groups.google.com is fast; feed 'em '"java button tool tip  text set"

Finally, when using the UI classes, if there's a choice between a "Thingy" and a "JThingy", chose the "JThingy"; they're more 'modern' and more fully featured (it's 'java.awt.... vs. javax.swing....)

Good Luck,


<quote author='Jon Harman'>
Hi Albert,

Thanks for the info.  My plugin uses java.awt.Button.  I built it
originally using the Panel_Window example.  Is it possible to use
JButtons in my panel without much effort?  The differences between all
the Java interface components are extremely arcane to someone like me

... sniip...