X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FFontComboBox.java;h=7870a30e5e0e157dccc11669ead10ce3f78b21aa;hb=c63257e8cc0ba1a5aca9364b22171abe7279d479;hp=8c37cb49ea8c8c43ff8f498a08ba6a4a6529409f;hpb=e2489e5489979a2bce236682a354003914a0a31b;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/gui/FontComboBox.java b/src/net/pterodactylus/jsite/gui/FontComboBox.java index 8c37cb4..7870a30 100644 --- a/src/net/pterodactylus/jsite/gui/FontComboBox.java +++ b/src/net/pterodactylus/jsite/gui/FontComboBox.java @@ -35,21 +35,27 @@ import javax.swing.ListCellRenderer; * * @see GraphicsEnvironment#getAllFonts() * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ */ public class FontComboBox extends JComboBox { + /** The font names. */ + private static final String[] fontNames; + + static { + Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); + 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(); - Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); - String[] fontNames = new String[allFonts.length]; - int fontIndex = 0; - for (Font font: allFonts) { - fontNames[fontIndex++] = font.getName(); - } setModel(new DefaultComboBoxModel(fontNames)); setRenderer(new FontCellRenderer()); } @@ -58,7 +64,6 @@ public class FontComboBox extends JComboBox { * The cell renderer for the font name cells. * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ */ private static class FontCellRenderer extends JLabel implements ListCellRenderer {