*/
package jalview.gui;
-import jalview.util.MessageManager;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JScrollBar;
import javax.swing.SwingConstants;
+import jalview.util.MessageManager;
+
/**
* useful functions for building Swing GUIs
*
public static String wrapTooltip(boolean enclose, String ttext)
{
ttext = ttext.trim();
- if (ttext.length() < 60)
+ boolean maxLenghtExceeded = false;
+
+ if (ttext.contains("<br>"))
+ {
+ String[] htmllines = ttext.split("<br>");
+ for (String line : htmllines)
+ {
+ maxLenghtExceeded = line.length() > 60;
+ if (maxLenghtExceeded)
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ maxLenghtExceeded = ttext.length() > 60;
+ }
+
+ if (!maxLenghtExceeded)
{
return enclose ? "<html>" + ttext + "</html>" : ttext;
}
else
{
- return (enclose ? "<html>" : "")
- + "<table width=350 border=0><tr><td>" + ttext
- + "</td></tr></table>" + ((enclose ? "</html>" : ""));
+ return (enclose ? "<html><table width=350 border=0><tr><td align=justify>"
+ : "")
+ + ttext + ((enclose ? "</td></tr></table></html>" : ""));
}
}