It's not a secret anymore!
The moose likes Swing / AWT / SWT and the fly likes To have multi line tooltip text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "To have multi line tooltip text" Watch "To have multi line tooltip text" New topic

To have multi line tooltip text

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I need to have a multiline tooltip text...this is to represent the address of a person as the tool tip when the mouse is moved on to it.In general we will have tool tip text of single line and that extends tooo long for the complete i need multiple line tooltip text.
johny sill

Joined: Jul 08, 2006
Posts: 27
U can use StringBuffer ,

public String getText(String no) throws Exception
StringBuffer Info = new StringBuffer ();
Info.append ( "<html>\n" );
Info.append ( "<body bgcolor='#FFFFEE'>\n" );
Info.append ( "<td>\n" );
Info.append ( str1[i]+"\n" );
Info.append ( "</td>\n" );

Then u set it in tooltip

JLabel lab=new JLabel()
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Use HTML to format the tool tip:

component.setTooltipText("<html>line 1<br>line2<br>line3...</html>");

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: To have multi line tooltip text
jQuery in Action, 3rd edition