Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-line tooltips in Java?

I'm trying to display tooltips in Java which may or may not be paragraph-length. How can I word-wrap long tooltips?

like image 281
Amanda S Avatar asked May 15 '09 13:05

Amanda S


People also ask

How do I display tooltip in multiple lines?

Multiline tooltips allow text to be displayed on more than one line. They are supported by version 4.70 and later of the common controls. Your application creates a multiline tooltip by sending a TTM_SETMAXTIPWIDTH message, specifying the width of the display rectangle.

What is a tooltip in Java?

Tooltips are small windows of text that popup when the user leaves the mouse cursor over a component for a second or two. They are used to explain the functionality of the component.

Which contains a tab with tooltip in Java?

Use tabbedPane. addTab to add a tool tip.

What is tooltip content?

1. Alternatively known as a balloon, help balloon, flyover help, or ScreenTip, a Tooltip is a text description near an object. The tooltip is displayed when the user hovers the mouse cursor over the object.


2 Answers

If you wrap the tooltip in <html> and </html> tags, you can break lines with <br> tags. See https://web.archive.org/web/20060625031340/http://www.jguru.com/faq/view.jsp?EID=10653 for examples and discussion. Main take-awy from that discussion: fButton.setToolTipText("<html><font face=\"sansserif\" color=\"green\">first line<br>second line</font></html>");

Or you can use the JMultiLineToolTip class that can be found many places on the net, including https://github.com/ls-cwi/yoshiko-app/blob/master/src/main/java/com/yoshiko/internal/view/JMultiLineToolTip.java

like image 51
Paul Tomblin Avatar answered Sep 22 '22 11:09

Paul Tomblin


Tooltip text which starts with "<html>" will be treated as HTML. Of course that might be very wide HTML.

You can override JComponent.createTooltip to replace the tooltip with your own component which can display whatevee you like.

like image 29
Tom Hawtin - tackline Avatar answered Sep 20 '22 11:09

Tom Hawtin - tackline