I want to add multiline tooltip message to my swing component. The basic solution is to use html tags like this:
label.setToolTipText("<html><p width=\"350px\">" + text + "</p></html>");
It works fine with long text. But if the text, let's say, contains only one word it also will have fixed 350px width with a lot of empty space.
Is there any special html property for max-width which will work properly with setToolTipText() method? I tried the next solution but it doesn't work:
"<p style=\"max-width: 350px\">"
Should I calculate text width in pixels and change opening <p>
tag if width lesser than 350 px?