From: David ‘Bombe’ Roden Date: Sat, 26 Apr 2008 03:55:22 +0000 (+0000) Subject: initialize font names before creation X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ca94f6a6a70ebf3be560e4f29c441de95277bf26;p=jSite2.git initialize font names before creation git-svn-id: http://trooper/svn/projects/jSite/trunk@765 c3eda9e8-030b-0410-8277-bc7414b0a119 --- 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()); }