*/
public final class JvSwingUtils
{
+ static final String HTML_PREFIX = "<html><div style=\"width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;\">";
+
/**
* wrap a bare html safe string to around 60 characters per line using a CSS
* style class specifying word-wrap and break-word
"Tootip text to format must not be null!");
ttext = ttext.trim();
boolean maxLengthExceeded = false;
-
- if (ttext.contains("<br>"))
+ boolean isHTML = ttext.startsWith("<html>");
+ if (isHTML)
+ {
+ ttext = ttext.substring(6);
+ }
+ if (ttext.endsWith("</html>"))
+ {
+ isHTML = true;
+ ttext = ttext.substring(0, ttext.length() - 7);
+ }
+ boolean hasBR = ttext.contains("<br>");
+ enclose |= isHTML || hasBR;
+ if (hasBR)
{
String[] htmllines = ttext.split("<br>");
for (String line : htmllines)
{
return enclose ? "<html>" + ttext + "</html>" : ttext;
}
-
- return (enclose ? "<html><div style='width:350px'>"
-
- // BH 2018,2019
-
- + "<style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style><div class=\"ttip\">"
- + ttext
- + " </div></div>"
- + "</html>" : ttext);
+ // BH 2018,2019
+ return (enclose ? HTML_PREFIX + ttext + "</div></html>" : ttext);
}
combo.setToolTipText(tooltips.get(j));
}
}
+
@Override
public void mouseExited(MouseEvent e)
{