This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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

Win a copy of Head First Android this week in the Android forum!
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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: To have multi line tooltip text
It's not a secret anymore!