JAL-1683 replace year/version strings with tokens in source
[jalview.git] / src / jalview / gui / JvSwingUtils.java
index d546584..c5dd7b6 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  */
 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());
+  }
+
 }