com.sas.visuals
Class FontDialog

com.sas.visuals.FontDialog
All Implemented Interfaces:
ContainerInterface, VisualInterface, com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.ComponentInterface, com.sas.DesignTimeDropTargetInterface, com.sas.lang.StringDataInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, ValidatorInterface, com.sas.ViewInterface, MessageBoxSource, MultipleValueEventSourceInterface, java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class FontDialog
implements java.awt.event.WindowListener, java.awt.event.ActionListener, java.awt.event.FocusListener, MessageBoxSource

FontDialog is a subclass of Dialog which displays components for font creation and a set of buttons to allow a user response. The dialog can be modal or non-modal. When a button is selected by the user, a MessageBoxEvent is sent to all registered MessageBoxListeners. Listening for this event is necessary to use the FontDialog non-modally. When the FontDialog is modal, the selection of a button causes the SelectedButton property to be set on the FontDialog. After the call to show() on a modal FontDialog, SelectedButton indicates which button was pressed.

On Windows NT (at least), there is a button in the upper right hand corner of the FontDialog with an "x". When this button is pressed, it is as if the user pressed "Cancel". So, users of the FontDialog should properly handle the "Cancel" button even if there is not one in the FontDialog.

WARNING: At least until JDK version 1.1.2 there are bugs in AWT modal dialog handling. An application using a modal dialog may hang, partially hang, or improperly display the modal dialog.

A sample use of the FontDialog (non-modally) might look like :

     FontDialog FontDialog = new FontDialog( frame);
     FontDialog.initialize();
     FontDialog.addMessageBoxListener(this);
     FontDialog.setVisible(true);
 

The user of the FontDialog would then need to listen for MessageBoxEvents. The MessageBoxEvent contains an integer indicating which button was selected.

A sample use of the FontDialog (modally) might look like :

     FontDialog FontDialog = new FontDialog( frame,true);
     FontDialog.initialize();
     FontDialog.setVisible(true);
     switch (FontDialog.getSelectedButton() )
     {
         case FontDialog.BUTTON_OK:
             break;
         case FontDialog.BUTTON_CANCEL:
             break;
     } // switch
 

The font created by selections in the comboBoxes can be accessed through the getSelectedFont method. A font can be set through the setSelectedFont(Font ft) method.

See Also:
MessageBoxEvent, MessageBoxListener, MessageBoxSource, MessageBoxListenerList, Serialized Form

Field Summary
static int BUTTON_CANCEL
           
static int BUTTON_OK
           
protected  Button buttonCancel
           
protected  Button buttonOK
           
static int BUTTONS_OK_CANCEL
           
protected  FontPanel fp
           
protected  Button lastButtonWithFocus
           
protected  MessageBoxListenerList messageBoxListenerList
           
static java.lang.String RB_KEY
           
protected  int selectedButton
           
 
Fields inherited from class com.sas.awt.Dialog
_cantUseSASModal, _inApplet, _modal, autoDispose, READY, setVisibleCalled, t
 
Constructor Summary
FontDialog(java.awt.Frame frame)
          Construct a FontDialog owned by a given Frame.
FontDialog(java.awt.Frame frame, boolean modal)
          Construct a FontDialog owned by a given Frame.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          actionPerformed handles ActionEvents from the buttons in the FontDialog.
 void addMessageBoxListener(MessageBoxListener listener)
          This is part of the MessageBoxSource interface implementation.
protected  void commonInit()
          commonInit performs all the common functionality between the constructors of the FontDialog.
 void fireMessageBoxEvent(int button)
          Sends a MessageBoxEvent to all of the registered listeners.
 void focusGained(java.awt.event.FocusEvent event)
           
 void focusLost(java.awt.event.FocusEvent event)
           
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
           
 int getSelectedButton()
          getSelectedButton can be called on the FontDialog to return the button selected.
 java.awt.Font getSelectedFont()
          Returns the font created
protected  java.lang.String paramString()
          paramString returns information about the FontDialog in String format.
 void removeMessageBoxListener(MessageBoxListener listener)
          This is part of the MessageBox interface implementation.
 void setSelectedFont(java.awt.Font nf)
          Set the font
 void setVisible(boolean visible)
          setVisible sets the selectedButton property to zero to indicate that no button has been selected.
 void windowActivated(java.awt.event.WindowEvent e)
          Part of the implementation of the WindowListener interface.
 void windowClosed(java.awt.event.WindowEvent e)
          Part of the implementation of the WindowListener interface.
 void windowClosing(java.awt.event.WindowEvent e)
          Part of the implementation of the WindowListener interface.
 void windowDeactivated(java.awt.event.WindowEvent e)
          Part of the implementation of the WindowListener interface.
 void windowDeiconified(java.awt.event.WindowEvent e)
          Part of the implementation of the WindowListener interface.
 void windowIconified(java.awt.event.WindowEvent e)
          Part of the implementation of the WindowListener interface.
 void windowOpened(java.awt.event.WindowEvent e)
          Part of the implementation of the WindowListener interface.
 
Methods inherited from class com.sas.awt.Dialog
center, centerOver, centerOverWindow, dispose, fireReadySignal, getAutoDispose, getDefaultHeight, getDefaultWidth, getText, hide, isSASModalEnabled, newDispatchThread, processWindowEvent, setAutoDispose, setDefaultHeight, setDefaultWidth, setModal, setResizable, setSASModalEnabled, setText, setTitle, setVisible, show, stopDispatchThread, waitForReadySignal, waitTilReady
 
Methods inherited from class com.sas.awt.DialogContainerComponent
addNotify, clone, dragEnter, dragLeave, dragOver, drop, getContainerInterfaceSupportInfo, getErrorHandler, getInsets, getValidator, isIDEDnDDropBarrier, isIDEDnDDropTarget, isValid, removeNotify, setContainerInterfaceSupportInfo, setDefaultValues, setErrorHandler, setIDEDnDDropBarrier, setIDEDnDDropTarget, setInsets, setInsets, setValidator, superAddNotify, superGetInsets, superRemoveNotify, superSetDefaultValues
 
Methods inherited from class com.sas.awt.DialogVisualComponent
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, computePreferredSize, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getBackgroundColor, getBorder, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getFont, getForegroundColor, getHeight, getHorizontalPosition, getLinkInfo, getMinimumSize, getModelInterface, getPreferredSize, getPrePainter, getRequiredInterfaces, getVerticalPosition, getViewInterfaceSupportInfo, getVisualInterfaceSupportInfo, getWidth, initialize, initializeComponent, isDesignTime, isEnabled, isFocus, isLinked, isTransparent, isVisible, paint, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setBackgroundColor, setBorder, setBounds, setComponentDescription, setComponentSupportInfo, setEnabled, setFocus, setFont, setForegroundColor, setHeight, setHorizontalPosition, setLinkInfo, setModelInterface, setPreferredSize, setPrePainter, setRequiredInterfaces, setTransparent, setVerticalPosition, setViewInterfaceSupportInfo, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, update, validateObject
 
Methods inherited from interface com.sas.awt.ContainerInterface
getComponents, getLayout, invalidate, setLayout, validate
 
Methods inherited from interface com.sas.awt.VisualInterface
computePreferredSize, getBackgroundColor, getBorder, getFont, getForegroundColor, getHeight, getHorizontalPosition, getMinimumSize, getPreferredSize, getPrePainter, getVerticalPosition, getVisualInterfaceSupportInfo, getWidth, isEnabled, isFocus, isTransparent, isVisible, setBackgroundColor, setBorder, setBounds, setEnabled, setFocus, setFont, setForegroundColor, setHeight, setHorizontalPosition, setPreferredSize, setPrePainter, setTransparent, setVerticalPosition, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values

BUTTON_OK

public static final int BUTTON_OK
See Also:
Constant Field Values

BUTTON_CANCEL

public static final int BUTTON_CANCEL
See Also:
Constant Field Values

BUTTONS_OK_CANCEL

public static final int BUTTONS_OK_CANCEL
See Also:
Constant Field Values

lastButtonWithFocus

protected Button lastButtonWithFocus

selectedButton

protected int selectedButton

fp

protected FontPanel fp

buttonOK

protected Button buttonOK

buttonCancel

protected Button buttonCancel

messageBoxListenerList

protected MessageBoxListenerList messageBoxListenerList
Constructor Detail

FontDialog

public FontDialog(java.awt.Frame frame)
Construct a FontDialog owned by a given Frame. The FontDialog will have a title of "Font", and be non-modal.

Parameters:
frame - The frame to own the FontDialog.

FontDialog

public FontDialog(java.awt.Frame frame,
                  boolean modal)
Construct a FontDialog owned by a given Frame.

Parameters:
frame - The frame to own the FontDialog.
modal - Whether the FontDialog is modal.
Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

commonInit

protected void commonInit()
commonInit performs all the common functionality between the constructors of the FontDialog. It creates all the controls in the FontDialog.


setVisible

public void setVisible(boolean visible)
setVisible sets the selectedButton property to zero to indicate that no button has been selected. This is useful when the same FontDialog is shown multiple times.

Specified by:
setVisible in interface VisualInterface
Overrides:
setVisible in class Dialog
Parameters:
visible - Whether the component should be visible.
See Also:
VisualInterface.setVisible(boolean)

paramString

protected java.lang.String paramString()
paramString returns information about the FontDialog in String format. This is use by toString() on java.awt.Component subclasses.

Overrides:
paramString in class java.awt.Dialog

getSelectedFont

public java.awt.Font getSelectedFont()
Returns the font created

Returns:
font

setSelectedFont

public void setSelectedFont(java.awt.Font nf)
Set the font

Parameters:
nf - the selected font

getSelectedButton

public int getSelectedButton()
getSelectedButton can be called on the FontDialog to return the button selected. If there has not been a button selected, zero will be returned. Otherwise, the number indicating the button will be returned. This is the same number that is delivered in the MessageBoxEvent when a button is selected. This method is useful when you have a modal FontDialog and do not want to listen for MessageBoxEvents. When using this method with a modal FontDialog, you can call it after the show() method.


windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Part of the implementation of the WindowListener interface. This interface is used to listen for the close event on the window.

Specified by:
windowOpened in interface java.awt.event.WindowListener
Overrides:
windowOpened in class Dialog
Parameters:
e - windowEvent

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Part of the implementation of the WindowListener interface. This interface is used to listen for the close event on the window.

When the window close button is clicked, a MessageEvent is sent with the button field as CANCEL and the window is hidden using dipose().

Specified by:
windowClosing in interface java.awt.event.WindowListener
Overrides:
windowClosing in class Dialog
Parameters:
e - windowEvent

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Part of the implementation of the WindowListener interface. This interface is used to listen for the close event on the window.

Specified by:
windowClosed in interface java.awt.event.WindowListener
Overrides:
windowClosed in class Dialog
Parameters:
e - windowEvent

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Part of the implementation of the WindowListener interface. This interface is used to listen for the close event on the window.

Specified by:
windowIconified in interface java.awt.event.WindowListener
Overrides:
windowIconified in class Dialog
Parameters:
e - windowEvent

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Part of the implementation of the WindowListener interface. This interface is used to listen for the close event on the window.

Specified by:
windowDeiconified in interface java.awt.event.WindowListener
Overrides:
windowDeiconified in class Dialog
Parameters:
e - windowEvent

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Part of the implementation of the WindowListener interface. This interface is used to listen for the close event on the window.

Specified by:
windowActivated in interface java.awt.event.WindowListener
Overrides:
windowActivated in class Dialog
Parameters:
e - windowEvent

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Part of the implementation of the WindowListener interface. This interface is used to listen for the close event on the window.

Specified by:
windowDeactivated in interface java.awt.event.WindowListener
Overrides:
windowDeactivated in class Dialog
Parameters:
e - windowEvent

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed handles ActionEvents from the buttons in the FontDialog. When a button is selected, the button number corresponding to the button component is determined. Then, a MessageBoxEvent is sent.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

focusGained

public void focusGained(java.awt.event.FocusEvent event)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent event)
Specified by:
focusLost in interface java.awt.event.FocusListener

addMessageBoxListener

public void addMessageBoxListener(MessageBoxListener listener)
This is part of the MessageBoxSource interface implementation. Components which want to listen for MessageBoxEvents should call this method to register themselves.

Specified by:
addMessageBoxListener in interface MessageBoxSource
Parameters:
listener - an object which handles MessageBoxEvent events the listener is not added a second time if it already exists in the list of listeners for this event.
See Also:
removeMessageBoxListener(com.sas.visuals.MessageBoxListener), fireMessageBoxEvent(int)

removeMessageBoxListener

public void removeMessageBoxListener(MessageBoxListener listener)
This is part of the MessageBox interface implementation. Components which want to stop listening for MessageBoxEvents should call this method to unregister themselves.

Specified by:
removeMessageBoxListener in interface MessageBoxSource
Parameters:
listener - an object which handles MessageBoxEvent events
See Also:
addMessageBoxListener(com.sas.visuals.MessageBoxListener), fireMessageBoxEvent(int)

fireMessageBoxEvent

public void fireMessageBoxEvent(int button)
Sends a MessageBoxEvent to all of the registered listeners.

See Also:
addMessageBoxListener(com.sas.visuals.MessageBoxListener), removeMessageBoxListener(com.sas.visuals.MessageBoxListener)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.