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