Merge commit
[jalview.git] / src / jalview / gui / JvSwingUtils.java
index d546584..b4e0e00 100644 (file)
  */
 package jalview.gui;
 
+import jalview.util.MessageManager;
+
 import java.awt.Color;
 import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.ActionListener;
 
+import javax.swing.AbstractButton;
 import javax.swing.JButton;
 import javax.swing.JComponent;
 import javax.swing.JLabel;
@@ -53,14 +56,14 @@ public final class JvSwingUtils
    */
   public static String wrapTooltip(boolean enclose, String ttext)
   {
-         
     if (ttext.length() < 60)
     {
-      return enclose ? "<html>"+ttext+"</html>" : ttext;
+      return enclose ? "<html>" + ttext + "</html>" : ttext;
     }
     else
     {
-      return (enclose ? "<html>" : "") + "<table width=350 border=0><tr><td>" + ttext
+      return (enclose ? "<html>" : "")
+              + "<table width=350 border=0><tr><td>" + ttext
               + "</td></tr></table>" + ((enclose ? "</html>" : ""));
     }
   }
@@ -209,4 +212,24 @@ public final class JvSwingUtils
     }
   }
 
+  public static void jvInitComponent(AbstractButton comp, String i18nString)
+  {
+    setColorAndFont(comp);
+    if (i18nString != null && !i18nString.isEmpty())
+    {
+      comp.setText(MessageManager.getString(i18nString));
+    }
+  }
+
+  public static void jvInitComponent(JComponent comp)
+  {
+    setColorAndFont(comp);
+  }
+
+  private static void setColorAndFont(JComponent comp)
+  {
+    comp.setBackground(Color.white);
+    comp.setFont(JvSwingUtils.getLabelFont());
+  }
+
 }