X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FFontComboBox.java;h=02ec429f753f286e03a9f4d84bacd77d081805b7;hb=a2bc5cc3fa7c6d2324b1d9297d77eb79a237fb6e;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..02ec429 100644 --- a/src/net/pterodactylus/jsite/gui/FontComboBox.java +++ b/src/net/pterodactylus/jsite/gui/FontComboBox.java @@ -32,31 +32,38 @@ import javax.swing.ListCellRenderer; /** * Combobox that displays a list of all available fonts, showing the name of the * font in the font itself. - * + * * @see GraphicsEnvironment#getAllFonts() * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ */ 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()); } /** * The cell renderer for the font name cells. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> * @version $Id$ */