Project

General

Profile

Actions

Font Chooser

Features

Font chooser panel horizontal layout
Font chooser panel horizontal layout
Font chooser panel vertical layout
Font chooser panel vertical layout
Font chooser dialog
Font chooser dialog

The font chooser provides a panel where the user can choose the font name, font style and font size. The panel have two different layouts: horizontal and vertical. The panel have a preview and a undo feature. An optional cancel button can be shown.

Examples

Font Chooser Panel added in a user JPanel:

injector = Guice.createInjector(
                new FontChooserModule(),
                new FontChooserDefaultsModule(),
                new SwingPropertiesModule(),
                new GroovyEvaluatingModule());
// ...
factory = injector.getInstance(FontChooserFactory.class);
panelFactory = injector.getInstance(DefaultFontChooserPanelFactory.class);
model = injector.getInstance(FontModel.class);
panel = panelFactory.create(DefaultFontChooserPanelModule.VERTICAL_PANEL);
// or panel = panelFactory.create(DefaultFontChooserPanelModule.HORIZONTAL_PANEL);
fontChooser = factory.create(panel, model);
// ...
add(panel);
// ...
fontChooser.setApplyDefault(frame.getRootPane());
// ...
selectedFont = model.getFont();

Font Chooser Dialog:

injector = Guice.createInjector(
                new FontChooserModule(),
                new FontChooserDefaultsModule(),
                new SwingPropertiesModule(),
                new GroovyEvaluatingModule());
// ...
factory = injector.getInstance(FontChooserDialogFactory.class);
panelFactory = injector.getInstance(DefaultFontChooserPanelFactory.class);
// ...
dialog = new JDialog(frame, "Font Chooser", true);
model = injector.getInstance(FontModel.class);
panel = panelFactory.create(DefaultFontChooserPanelModule.HORIZONTAL_PANEL);
fontChooser = factory.create(dialog, panel, model);
dialog.setVisible(true);
// ...
selectedFont = model.getFont();

Updated by Erwin Mueller over 8 years ago · 14 revisions

Add picture from clipboard (Maximum size: 125 MB)