|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
PIRL.Viewers.Font_Selector
public class Font_Selector
A Font_Selector is a dialog box for selecting a named font and its size and style characteristics.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JDialog |
|---|
JDialog.AccessibleJDialog |
| Nested classes/interfaces inherited from class java.awt.Dialog |
|---|
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType |
| Nested classes/interfaces inherited from class java.awt.Window |
|---|
Window.AccessibleAWTWindow |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static Font |
DEFAULT_FONT
The default font when no other default is available: SansSerif 12-point plain. |
static Vector |
DEFAULT_SIZES
The Vector of default Integer font sizes: 9, 10, 12, 14, 16, 18, 24. |
static int |
MAXIMUM_SIZE
The maximum acceptable value for a font size: 256. |
static int |
MINIMUM_SIZE
The minimum acceptable value for a font size: 4. |
| Fields inherited from class javax.swing.JDialog |
|---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
| Fields inherited from class java.awt.Dialog |
|---|
DEFAULT_MODALITY_TYPE |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.WindowConstants |
|---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
Font_Selector()
Constructs a Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES and null title, default font and owner. |
|
Font_Selector(Font default_font)
Constructs a Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES and a null title and owner. |
|
Font_Selector(String title)
Constructs a Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES and a null default font and owner. |
|
Font_Selector(String title,
boolean select_font,
boolean select_style,
Vector select_sizes)
Constructs a Font_Selector with no "Apply" button, and
using a null default font and owner. |
|
Font_Selector(String title,
boolean select_font,
boolean select_style,
Vector select_sizes,
Font default_font)
Constructs a Font_Selector with no "Apply" button,
and using a null owner. |
|
Font_Selector(String title,
boolean select_font,
boolean select_style,
Vector select_sizes,
Font default_font,
ActionListener apply_listener,
Frame owner)
Constructs a Font_Selector containing the
specified font characteteristics selection lists. |
|
Font_Selector(String title,
boolean select_font,
boolean select_style,
Vector select_sizes,
Frame owner)
Constructs a Font_Selector with no "Apply" button, and
using a null default font. |
|
Font_Selector(String title,
Font default_font)
Constructs a Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES and a null owner. |
|
Font_Selector(String title,
Font default_font,
Frame owner)
Constructs a Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES. |
|
Font_Selector(String title,
Frame owner)
Constructs a Font_Selector with font and style
selections enabled and using the DEFAULT_SIZES and a
null default font. |
|
| Method Summary | |
|---|---|
void |
addActionListener(ActionListener apply_listener)
Adds an ActionListener to the "Apply" button. |
String |
Font_Name()
Gets the name of the current font. |
Font_Selector |
Font_Name(String name)
Sets the current font to the named family. |
Font |
Font()
Gets the current font. |
Font_Selector |
Font(Font font)
Set the current font. |
Font_Selector |
Font(String name,
int style,
int size)
Set the current font name, style and size. |
ActionListener[] |
getActionListeners()
Gets an array of ActionListeners currently registered
with the "Apply" button. |
void |
itemStateChanged(ItemEvent event)
The method that implements the ItemListener interface to listen for list selections. |
static void |
main(String[] arguments)
|
int |
Nearest_Size(int size)
Gets the size from the selection list that is nearest to a specified size. |
Font |
Original_Font()
Gets the original font. |
void |
removeActionListener(ActionListener apply_listener)
Removes an ActionListener, if registered, from the
"Apply" button, if present. |
void |
Reset()
Resets the current font to the original font. |
Font |
Select()
Initiates a Select operation using the previous
original font. |
Font |
Select(Font default_font)
Initiates a user interactive font selection. |
void |
setVisible(boolean set_visible)
Sets the dialog to be visible on the display. |
int |
Size()
Gets the size of the current font. |
Font_Selector |
Size(int size)
Sets the size of the current font. |
static String |
Style_Description(int style)
Provides a description of a style value. |
int |
Style()
Gets the style of the current font. |
Font_Selector |
Style(int style)
Sets the style of the current font. |
String |
Text()
Gets the current sample text. |
Font_Selector |
Text(String text)
Sets the text to be displayed in the current font. |
| Methods inherited from class java.awt.Dialog |
|---|
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, show, toBack |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Font DEFAULT_FONT
public static final Vector DEFAULT_SIZES
public static final int MINIMUM_SIZE
public static final int MAXIMUM_SIZE
| Constructor Detail |
|---|
public Font_Selector(String title,
boolean select_font,
boolean select_style,
Vector select_sizes,
Font default_font,
ActionListener apply_listener,
Frame owner)
Font_Selector containing the
specified font characteteristics selection lists.
Note: If no selection characteristics lists are enabled, then
the dialog will not appear when setVisible. The resulting
object will still provide correct responses to all of its methods,
however.
title - The String to be used as the title on the dialog box.
If this is null, then the title will be "Font_Selector".select_font - If true, a pull-down list of all available font
family names is included
on the selection panel. If false, no font selection is provided.select_style - If true, a pull-down list of the four possible
font styles - plain, bold, italic, and bold plus italic - is
is included on the selection panel. If false, no style selection
is provided.select_sizes - A Vector of Integer values listing the
allowable font sizes to included in a pull-down on the
selection panel. The list will be numerically sorted and
duplicate values will be removed. If the list contains two
values and the second value is negative, then all values in the
range [first,-second] will be included in the selection list.
Any value less than the MINIMUM_SIZE or greater than the MAXIMUM_SIZE is excluded. If the Vector
is empty, or all of the listed values are outside of the
acceptable range, then the DEFAULT_SIZES will be used. If the Vector is null, no
size selection is provided (but the DEFAULT_SIZES
will still be the effective selection sizes).default_font - The Font to use as the original, default,
font. If the default_font is null and there is a non-null
owner, then the font from the owner will be used; otherwise the
default front from the dialog will be used. If this fails to
produce a non-null font, then the DEFAULT_FONT will be used. If the size of the final
default font is not one of the selection sizes, then the
Nearest_Size to the
font size in the selection list will be used.apply_listener - An ActionListener that will be associated
with an "Apply" button. When the button is pressed the button
will call the listener's
{#ActionListener.actionPerformed(ActionEvent)
actionPerformed} method. If null, then no button will
appear; but it can be added later, if desired, by using the
addActionListener method.owner - The parent Frame of the dialog. This may be null.
public Font_Selector(String title,
boolean select_font,
boolean select_style,
Vector select_sizes,
Font default_font)
Font_Selector with no "Apply" button,
and using a null owner.
Font_Selector(String, boolean, boolean, Vector, Font,
ActionListener, Frame)
public Font_Selector(String title,
boolean select_font,
boolean select_style,
Vector select_sizes,
Frame owner)
Font_Selector with no "Apply" button, and
using a null default font.
Font_Selector(String, boolean, boolean, Vector, Font,
ActionListener, Frame)
public Font_Selector(String title,
boolean select_font,
boolean select_style,
Vector select_sizes)
Font_Selector with no "Apply" button, and
using a null default font and owner.
Font_Selector(String, boolean, boolean, Vector, Font,
ActionListener, Frame)
public Font_Selector(String title,
Font default_font,
Frame owner)
Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES.
Font_Selector(String, boolean, boolean, Vector, Font,
ActionListener, Frame)
public Font_Selector(String title,
Font default_font)
Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES and a null owner.
Font_Selector(String, boolean, boolean, Vector, Font,
ActionListener, Frame)
public Font_Selector(String title,
Frame owner)
Font_Selector with font and style
selections enabled and using the DEFAULT_SIZES and a
null default font.
Font_Selector(String, boolean, boolean, Vector, Font,
ActionListener, Frame)public Font_Selector(String title)
Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES and a null default font and owner.
Font_Selector(String, boolean, boolean, Vector, Font,
ActionListener, Frame)public Font_Selector(Font default_font)
Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES and a null title and owner.
Font_Selector(String, boolean, boolean, Vector, Font,
ActionListener, Frame)public Font_Selector()
Font_Selector with font and style
selections enabled, with no "Apply" button, and using the
DEFAULT_SIZES and null title, default font and owner.
Font_Selector(String, boolean, boolean, Vector, Font,
ActionListener, Frame)| Method Detail |
|---|
public void itemStateChanged(ItemEvent event)
itemStateChanged in interface ItemListenerpublic void Reset()
public void setVisible(boolean set_visible)
Note: If no selection lists were enabled when this
Font_Selector was constructed, then it will
never become visible.
setVisible in class Dialogpublic void addActionListener(ActionListener apply_listener)
ActionListener to the "Apply" button.
If no "Apply" button is present, one is added.
apply_listener - The ActionListener for the
"Apply" button.public void removeActionListener(ActionListener apply_listener)
ActionListener, if registered, from the
"Apply" button, if present.
apply_listener - The ActionListener to be
removed from the "Apply" button.public ActionListener[] getActionListeners()
ActionListeners currently registered
with the "Apply" button.
ActionListener array. This will be empty
if there is no "Apply" button, or no ActionListener
is registered with the button.public Font_Selector Font(Font font)
If the font has a size that is not in the size selection list,
then the in
the selection list will be applied to the font.
Nearest_Size
font - The Font to become the current font.
public Font_Selector Font(String name,
int style,
int size)
The name must be an available font name.
The style must be one of the Font class
style constants.
If the font has a size that is not in the size selection list,
then the in
the selection list will be applied to the font.
Nearest_Size
name - The String providing a valid font family name.style - A Font class style value.size - The point size for the font.
Fontpublic Font Font()
public Font Original_Font()
Font_Selector was constructed or when
the Select method was used.public Font_Selector Font_Name(String name)
name - The font family name to be applied.
public String Font_Name()
public Font_Selector Style(int style)
style - A Font class style value.
public int Style()
Font class style value of the current font.public static String Style_Description(int style)
style - A Font class style value.
public Font_Selector Size(int size)
size - The font size.
Font(String, int, int)public int Size()
public int Nearest_Size(int size)
If the size is less than the smallest selection size, then the smallest size will be returned. If the size is greater than the largest selection size, then the largest size will be returned. Otherwise the selection size nearest to the specified size, rounded up, is returned.
size - The size to use in searching for the nearest
size in the selection list.public Font_Selector Text(String text)
text - The String of text to be displayed.
public String Text()
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
0123456789 ~!@#$%^&*()_+`-=[]\\{}|;':\"<>?,./
public Font Select(Font default_font)
This dialog is .
When the user completes the selection or closes the dialog, the
current font is returned. If the "Cancel" button is pressed, then
the original font is restored before the selection operation completes.
setVisible
default_font - The font to be the original, default
font for the selection. If null, then the previous original
font is used.
public Font Select()
Select operation using the previous
original font.
Select(Font)public static void main(String[] arguments)
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||