From ca94f6a6a70ebf3be560e4f29c441de95277bf26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 26 Apr 2008 03:55:22 +0000 Subject: [PATCH] initialize font names before creation git-svn-id: http://trooper/svn/projects/jSite/trunk@765 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/jsite/gui/FontComboBox.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/net/pterodactylus/jsite/gui/FontComboBox.java b/src/net/pterodactylus/jsite/gui/FontComboBox.java index 8c37cb4..1dcb77e 100644 --- a/src/net/pterodactylus/jsite/gui/FontComboBox.java +++ b/src/net/pterodactylus/jsite/gui/FontComboBox.java @@ -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()); } -- 2.7.4