Posts Tagged ‘justify’

Long lines in Java Tooltips (or multiline tooltips)

Thursday, February 14th, 2008

Do you want to show a tooltip with more than one line? Are your tooltips too large to fit in one line? The solution is easier than you think. Tooltips, in Java, accept HTML code:

jcomponent.setToolTipText("HTML tooltip");

It isn’t a Firefox, but is very powerful. And, when I said HTML, I also think about CSS. So, you can set your tooltips using this evil cheat:

<html><body>
<div style=”width: 300px; text-justification: justify;”>
Blah Blah Blah (repeat “blah” 100 times)
</div>
</html></body>

Have you seen automatic line breaks and the justification? Oh, yeah!

BTW, do you remember old days, when you couldn’t believe WordPad didn’t have justified text? :)