Font Chooser Overview
- Provides a pane of controls designed to allow a user to select a font.
- Supports internationalization in English, French, German, Greek and Spanish.
- Lightweight Swing component.
- Distributed under the LGPL license.
- Implemented in the JFontChooser class located in the com.connectina.swing.fontchooser package.
- Integrates in the component palette of GUI builders for point and drop access.
- Screenshots appear in the main Connectina Swing Components page.
How do I add a Font Chooser?
The JFontChooser class inherits from javax.swing.JPanel so it can be added like any other panel.
JFontChooser fontChooser = new JFontChooser();
myPanel.add(fontChooser, BorderLayout.CENTER);
How do I display a Font Chooser dialog?
A static method named showDialog is provided for this.
JFont selectedFont = JFontChooser.showDialog(myFrame, null);
How do I listen for font selection changes?
This is done by a javax.swing.event.ChangeListener.
JFontChooser fontChooser = new JFontChooser();
fontChooser.addChangeListener(new FontSelectionListener());
...
class FontSelectionListener implements ChangeListener {
public void stateChanged(ChangeEvent e) {
System.out.println("Font selection changed to: " +
fontChooser.getSelectedFont());
}
}

