Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1262

Re: Is posible have multi

From "Mark Holland" <mark.holland@THRWHITE.remove-dii-this>
Subject Re: Is posible have multi
Message-ID <ets27l$4vl$1@news.freedom2surf.net> (permalink)
Newsgroups comp.lang.java.gui
References <ets1l8$eph$1@news.nems.noaa.gov>
Date 2011-04-27 15:32 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui,comp.l
"RC" <raymond.chui@nospam.noaa.gov> wrote in message 
news:ets1l8$eph$1@news.nems.noaa.gov...
>I tried
>
> String toolTipText = "Line1\nLine2\rLine3<br />";
>
> myJComponent.setToolTipText(toolTipText);
>
> But I only got the single line.
>
> Is possible to have multiple lines in ToolTip?
> If yes, how do I set the multiple line mode?
>
> Thank Q very much in advance!

It is possible to do this, since (I think) tool tips are displayed in 
a kind of customised JLabel.
You were fairly close with your first guess - the answer is to format 
your tool-tip text with html.

e.g.
String toolTipText = "<html>Line1<br>Line2<br>Line3</html>";
myJComponent.setToolTipText(toolTipText);

Of course, if you do this then you need to escape any special html 
characters in your text.
For example, if you want to display the text "a < b\n line2" then you 
need:

String toolTipText = "<html>a &lt; b<br> line2</html";

Because of this, some people have written their own classes which you 
can find using google.
One I found is this http://www.codeguru.com/java/articles/122.shtml, 
although I didn't test it.

Mark

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Is posible have multiple "RC" <rc@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
  Re: Is posible have multi "Mark Holland" <mark.holland@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000

csiph-web