File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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
 
Consider Paul's rocket mass heater.
 
subject: To have multi line tooltip text
 
Similar Threads
Setting TooltipText
Setting TooltipText
How to change Tooltip renderer?
How to implement tooltip with text box
Display the content of a variable without <h:outputText>?