borland Packages Class Hierarchy dbswing Package
java.lang.Object +----com.borland.dbswing.FontChooser
Constructors Properties Methods
Implements Serializable
FontChooser
is used to prompt a user to select a font name, style, and size. These are some of the useful features of FontChooser
:
Working with FontChooser
, you customize the initial display of font selection dialog with the following properties:
title
- Sets the title of the dialog box.
sampleText
- Sets the font text sample.
availableFontSizes
- The list of available font sizes.
allowAnyFontSize
- Allows or disallows the user to enter any font size.
modal
- Whether the dialog box is a modal or modeless dialog; if true
, the dialog is modal.
To display the FontChooser
, set the frame
property to a parent Frame
for the dialog box and then call the showDialog()
method.
When the dialog box appears, the user works with the dialog box to select a font and sets its attributes. If the user makes a font selection in the dialog box and chooses the OK button, showDialog()
saves the user's selection as the selectedFont
property. Your application can then inspect the selectedFont
property value to determine the user's selection. The showDialog()
method returns true
if the user selects a font and chooses the OK button.
public FontChooser()Constructs a modal
FontChooser
without a parent frame and title. Calls the constructor of this
class that takes a Frame
, a String
, and a boolean
as parameters. Passes default values of null
, an empty string (""), and true
to the other constructor.
public FontChooser(Frame frame, String title)Constructs a
FontChooser
with a specified parent frame and a specified text string on the title bar. Calls the constructor of this
class that takes a Frame
, a String
, and a boolean
as parameters. Passes the specified frame
and title
, along with a boolean
value of true
to the other constructor.
frame
title
public FontChooser(Frame frame, String title, boolean modal)Constructs a
FontChooser
with a specified parent frame, a string that appears as the title of the dialog box, and a boolean value that indicates whether the dialog is modal.
frame
title
modal
true
the dialog is modal.
public boolean isAllowAnyFontSize() public void setAllowAnyFontSize(boolean allowAnyFontSize)Determines whether the user can enter any font size in the dialog box. If
true
, the Font Size combo box is editable, allowing the user to enter any font size; otherwise, only sizes in the drop-down list can be selected. The default value is true
.
public Font[] getAvailableFonts() public void setAvailableFonts(Font[] availableFonts)Returns the list of font names displayed in the dialog box. Sets the list of font names displayed in the dialog box.
public String[] getAvailableFontSizes() public void setAvailableFontSizes(String[] availableFontSizes)Returns the list of font sizes displayed in the dialog box. Sets the list of font sizes displayed in the dialog box.
public Frame getFrame() public void setFrame(Frame frame)Returns and sets the
Frame
used for the dialog box. The frame
property must be set to a parent Frame
before the dialog box is displayed.
public boolean isModal() public void setModal(boolean modal)Returns whether the dialog box is modal or not. Sets whether the dialog box is modal or not.
public String getSampleText() public void setSampleText(String sampleText)Returns and sets the string that appears as the sample text string in the dialog box so the user can see how choosing a font, font size, and style options affect the look of text. If this property is not set, a default sample string appears in the dialog box that includes letters, numbers, and punctuation symbols.
public Font getSelectedFont() public void setSelectedFont(Font selectedFont)Returns the font name the user selected in the dialog box and sets the selected font in the dialog box.
public String getTitle() public void setTitle(String title)Returns and sets the string that appears as the title of the dialog box on the title bar.
public void show()Calls the
showDialog()
method. To determine whether the user entered a font and chose OK or canceled the dialog box, call showDialog()
instead.
public boolean showDialog()Displays the font selection dialog box and returns
true
if the user selected a font and chose OK. If the frame
property is null
, an IllegalStateException
is thrown.