JAL-854 tweaked menu layout so services appear before the fetch DB refs submenu
[jalview.git] / src / jalview / gui / JvSwingUtils.java
index 812353e..b921a81 100644 (file)
@@ -26,6 +26,7 @@ import javax.swing.JButton;
 import javax.swing.JComponent;
 import javax.swing.JLabel;
 import javax.swing.JMenu;
+import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JTextArea;
 import javax.swing.SwingConstants;
@@ -148,4 +149,46 @@ public final class JvSwingUtils
     jLabel.setToolTipText(tooltip);
   }
 
+  /**
+   * standard font for labels and check boxes in dialog boxes 
+   * @return
+   */
+
+  public static Font getLabelFont()
+  {
+    return getLabelFont(false,false);
+  }
+  public static Font getLabelFont(boolean bold, boolean italic)
+  {
+    return new java.awt.Font("Verdana", (!bold && !italic) ? Font.PLAIN : (bold ? Font.BOLD : 0) + (italic ? Font.ITALIC : 0), 11);
+  }
+
+  /**
+   * standard font for editable text areas
+   * @return
+   */
+  public static Font getTextAreaFont()
+  {
+    return getLabelFont(false,false);
+  }
+
+  /**
+   * clean up a swing menu. 
+   * Removes any empty submenus without selection listeners.
+   * @param webService
+   */
+  public static void cleanMenu(JMenu webService)
+  {
+    for (int i=0;i<webService.getItemCount(); )
+    {
+      JMenuItem item = webService.getItem(i);
+      if (item instanceof JMenu && ((JMenu)item).getItemCount()==0)
+      {
+        webService.remove(i);
+      } else {
+        i++;
+      }
+    }
+  }
+
 }