Description: Displays a dialog in which the user can select a font and its color, bold, italic and transparency attributes.
Copyright: Copyright (c) 2011
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.
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 |
public FontAndColorChooser(java.awt.Frame parent)
If a Frame, or Frame subclass, is avialable call with:
FontAndColorChooser fc = new FontAndColorChooser(this, true/false);
If a Frame, or Frame subclass, is not avialable call with:
FontAndColorChooser fc = new FontAndColorChooser(null, true/false);
If a frame is provided, the dialog is centered over that frame. Otherwise, the dialog is positioned 20 pixels down and to the right of the upper left corner of the display screen.
If the user presses the Cancel button all of the getter methods will return null
. If the user presses the OK button without selecting a color or font the getFont
will return a color of black (r=0,g=0,b=0) and getFont will return a system default font such as:
javax.swing.plaf.FontUIResource[family=Tahoma,name=Tahoma,style=plain,size=13]
Example usage:
FontAndColorChooser fc = new FontAndColorChooser(this);
Font font = fc.getNewFont();
Color color = fc.getNewColor();
AttributeSet atts = fc.getAttributes();
System.out.println("F&C -toString = " + fc.toString());
parent
- The Frame, or subclass, from which the dialog was called.Method Detail |
public java.awt.Color getNewColor()
public java.awt.Font getNewFont()
public javax.swing.text.AttributeSet getAttributes()
public java.lang.String toString()
Font=java.awt.Font[family=AR BERKLEY,name=AR BERKLEY,style=bolditalic,size=12] newColor=java.awt.Color[r=255,g=0,b=0] Attributes+bold=true italic=true family=AR BERKLEY