aspose file tools*
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
Author

To have multi line tooltip text

Anonymous
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 address.so i need multiple line tooltip text.
johny sill
Greenhorn

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" );
:
:
Info.append("<table>\n");
Info.toString();
}

Then u set it in tooltip

JLabel lab=new JLabel()
lab.setToolTipText(getText());
Ilja Preuss
author
Sheriff

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: To have multi line tooltip text