*
* @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());
}
* 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 {