I want to add a multi-line popup to my swing component. The main solution is to use html tags like this:
label.setToolTipText("<html><p width=\"350px\">" + text + "</p></html>");
It works great with long text. But if the text, say, contains only one word, it will also have a fixed width of 350 pixels with a lot of empty space.
Is there any special html property for max-width that will work correctly with the setToolTipText () method? I tried the following solution, but it does not work:
"<p style=\"max-width: 350px\">"
Should I calculate the width of the text in pixels and change the opening of the <p> tag if the width is less than 350 pixels?
source share