JAL-3253-applet JAL-3360 HTML tooltips not trimming properly; need <div>
[jalview.git] / src / jalview / gui / JvSwingUtils.java
index 79e0cef..c1c8c82 100644 (file)
@@ -61,7 +61,8 @@ public final class JvSwingUtils
    * style class specifying word-wrap and break-word
    * 
    * @param enclose
-   *          if true, add &lt;html&gt; wrapper tags
+   *          if true, add &lt;html&gt; wrapper tags (currently false for only
+   *          two references -- both in Jws2Discoverer --
    * @param ttext
    * 
    * @return
@@ -94,10 +95,12 @@ public final class JvSwingUtils
     {
       return enclose ? "<html>" + ttext + "</html>" : ttext;
     }
-
-    return (enclose ? "<html>" : "")
-            + "<style> p.ttip {width: 350; text-align: justify; word-wrap: break-word;}</style><p class=\"ttip\">"
-            + ttext + "</p>" + ((enclose ? "</html>" : ""));
+    // BH 2018,2019
+    return (enclose
+            ? "<html><div style=\"width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;\">"
+            + ttext
+                    + "</div></html>"
+            : ttext);
 
   }
 
@@ -356,12 +359,13 @@ public final class JvSwingUtils
 
   /**
    * Adds a titled border to the component in the default font and position (top
-   * left)
+   * left), optionally witht italic text
    * 
    * @param comp
    * @param title
+   * @param italic
    */
-  public static void createItalicTitledBorder(JComponent comp,
+  public static TitledBorder createTitledBorder(JComponent comp,
           String title, boolean italic)
   {
     Font font = comp.getFont();
@@ -374,6 +378,8 @@ public final class JvSwingUtils
             title, TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION,
             font);
     comp.setBorder(titledBorder);
+
+    return titledBorder;
   }
 
 }