fwpUtil
Class FontChooser

public class FontChooser
extends javax.swing.JDialog
implements java.awt.event.ActionListener
Title: Font chooser dialog.

Description: A font chooser dialog which suports setting the size, bold and italic properties of the font.

Copyright: Copyright (c) 2011

Version:
1.0 - 2011

Author:
Fred Pospeschil - This file is placed in the public domain and can be used and adapted without restrictions. The user of the code is totally responsible for insuring its suitability in the intended application.

NOTE: This JavaDoc file was post processed with Microsoft FrontPage and regenerating the file will cause the graphics and format changes to be lost.

 
Constructor Detail

FontChooser

public FontChooser(java.awt.Frame parent)
Displays a dialog in which the user can select a font.

A font chooser that allows users to pick a font by name, set the size and select whether the font should be bold and/or italic.

It can be called with FontChooser fc = new FontChooser(this); if a frame is avialable or it can be called with: FontChooser fc = new FontChooser(null); if a frame is not available.

This dialog is an adaptation of the font chooser presented in Java Swing by Robert Eckstein, Marc Loy & Dave Wood, O'Reilly, Sebastopol, CA 1998, ISBN 1-56592-455-X. See pages 381-387. The fixed list of fonts approach used by the O'Reilly example was replaced by the more general getting a list of all available fonts as described on pages 788-791 of Java for Dummies by Doug Lowe and Barry Burd, Wiley Publishing, Inc. 2007.

Parameters:
parent - The parent Frame from which this dialog was called. If the dialod is called with a valid parent the dialog will be positioned over the center of the parent. If a null is passed instead of a parent then the dialog will be located at the upper left of the screen.

Method Detail

getNewFont

public java.awt.Font getNewFont()
Returns the font and settings selected by the user.
Returns:
Font object

Usage example:
FontChooser dlg = new FontChooser(this);
Font font = dlg.getNewFont();
System.out.println("font=" + font);


toString

public java.lang.String toString()
Returns the font attributes.
Returns:
new font attributes.

For example:
javax.swing.plaf.FontUIResource[family=Tahoma,name=Tahoma,style=plain,size=13]