Merge branch 'develop' into update_212_Dec_merge_with_21125_chamges
[jalview.git] / src / jalview / gui / JvSwingUtils.java
index 8a735ed..a022c85 100644 (file)
@@ -35,8 +35,10 @@ import javax.swing.BorderFactory;
 import javax.swing.JButton;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
+import javax.swing.JLabel;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
+import javax.swing.JPanel;
 import javax.swing.JScrollBar;
 import javax.swing.SwingConstants;
 import javax.swing.border.Border;
@@ -57,7 +59,6 @@ public final class JvSwingUtils
           "<html><div style=\"max-width:350px;overflow-wrap:break-word;display:inline-block\">"
           : "<html><div style=\"width:350; text-align: justify; word-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
@@ -74,8 +75,8 @@ public final class JvSwingUtils
     Objects.requireNonNull(ttext,
             "Tootip text to format must not be null!");
     ttext = ttext.trim().replaceAll("<br/>", "<br>");
-
     boolean maxLengthExceeded = false;
+
     boolean isHTML = ttext.startsWith("<html>");
     if (isHTML)
     {
@@ -171,6 +172,29 @@ public final class JvSwingUtils
     label.setToolTipText(tooltip);
   }
 
+  // From 2.11.2 merge
+  public static void mgAddtoLayout(JPanel cpanel, String tooltip,
+          JLabel jLabel, JComponent name)
+  {
+    mgAddtoLayout(cpanel, tooltip, jLabel, name, null);
+  }
+
+  public static void mgAddtoLayout(JPanel cpanel, String tooltip,
+          JLabel jLabel, JComponent name, String params)
+  {
+    cpanel.add(jLabel);
+    if (params == null)
+    {
+      cpanel.add(name);
+    }
+    else
+    {
+      cpanel.add(name, params);
+    }
+    name.setToolTipText(tooltip);
+    jLabel.setToolTipText(tooltip);
+  }
+
   /**
    * standard font for labels and check boxes in dialog boxes
    *