JAL-1925 update source version in license
[jalview.git] / src / jalview / gui / FontChooser.java
index 92d2b2b..4fa9180 100755 (executable)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
+ * Copyright (C) 2015 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  */
 package jalview.gui;
 
+import jalview.bin.Cache;
+import jalview.jbgui.GFontChooser;
+import jalview.util.MessageManager;
+
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.event.ActionEvent;
+import java.awt.geom.Rectangle2D;
 
 import javax.swing.JInternalFrame;
 import javax.swing.JLayeredPane;
 import javax.swing.JOptionPane;
 
-import jalview.bin.Cache;
-import jalview.jbgui.GFontChooser;
-import jalview.util.MessageManager;
-
 /**
  * DOCUMENT ME!
  * 
@@ -241,15 +242,17 @@ public class FontChooser extends GFontChooser
             fontStyle.getSelectedIndex(),
             (Integer) fontSize.getSelectedItem());
     FontMetrics fm = getGraphics().getFontMetrics(newFont);
-    double mw = fm.getStringBounds("M", getGraphics()).getWidth(), iw = fm
-            .getStringBounds("I", getGraphics()).getWidth();
+    double mw = fm.getStringBounds("M", getGraphics()).getWidth();
+    final Rectangle2D iBounds = fm.getStringBounds("I", getGraphics());
+    double iw = iBounds.getWidth();
     if (mw < 1 || iw < 1)
     {
-      JOptionPane
-              .showInternalMessageDialog(
-                      this,
-                      MessageManager.getString("label.font_doesnt_have_letters_defined"),
-                      MessageManager.getString("label.invalid_font"), JOptionPane.WARNING_MESSAGE);
+      final String messageKey = iBounds.getHeight() < 1 ? "label.font_doesnt_have_letters_defined"
+              : "label.font_too_small";
+      JOptionPane.showInternalMessageDialog(this,
+              MessageManager.getString(messageKey),
+              MessageManager.getString("label.invalid_font"),
+              JOptionPane.WARNING_MESSAGE);
       /*
        * Restore the changed value - note this will reinvoke this method via the
        * ActionListener, but now validation should pass