• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To have multi line tooltip text

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use HTML to format the tool tip:

component.setTooltipText("<html>line 1<br>line2<br>line3...</html>");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic