initialize font names before creation
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 26 Apr 2008 03:55:22 +0000 (03:55 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 26 Apr 2008 03:55:22 +0000 (03:55 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@765 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/jsite/gui/FontComboBox.java

index 8c37cb4..1dcb77e 100644 (file)
@@ -39,17 +39,24 @@ import javax.swing.ListCellRenderer;
  */
 public class FontComboBox extends JComboBox {
 
-       /**
-        * Creates a new font combo box.
-        */
-       public FontComboBox() {
-               super();
+       /** The font names. */
+       private static final String[] fontNames;
+
+       static {
                Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
-               String[] fontNames = new String[allFonts.length];
+               System.out.println("got " + allFonts.length + " fonts");
+               fontNames = new String[allFonts.length];
                int fontIndex = 0;
                for (Font font: allFonts) {
                        fontNames[fontIndex++] = font.getName();
                }
+       }
+
+       /**
+        * Creates a new font combo box.
+        */
+       public FontComboBox() {
+               super();
                setModel(new DefaultComboBoxModel(fontNames));
                setRenderer(new FontCellRenderer());
        }