All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.visuals
Class ColorDialog

    com.sas.visuals.ColorDialog

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 ColorDialog

implements java.awt.event.WindowListener, java.awt.event.ActionListener, java.awt.event.FocusListener, MessageBoxSource

ColorDialog is a subclass of Dialog which displays components for color 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 ColorDialog non-modally. When the ColorDialog is modal, the selection of a button causes the SelectedButton property to be set on the ColorDialog. After the call to show() on a modal ColorDialog, SelectedButton indicates which button was pressed.

The Color Dialog supports displaying information about basic colors and can optionally display information about custom colors. To display information for custom colors, use the constructor with the format of:

       ColorDialog(frame fr, boolean modal, boolean custom)

where the value of custom determines whether custom color information will be displayed.

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

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 ColorDialog (non-modally) might look like :

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

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

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

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

The color created through component selection can be accessed through the getSelectedColor method. A color can be set through the setSelectedColor(Color cl) method.

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

Field Summary
`static int` | `BUTTON_CANCEL`
`static int` | `BUTTON_OK`
`protected Button` | `buttonAdd`
`protected Button` | `buttonCancel`
`protected Button` | `buttonOK`
`static int` | `BUTTONS_OK_CANCEL`
`protected ColorPanel` | `cp`
`protected Button` | `lastButtonWithFocus`
`protected MessageBoxListenerList` | `messageBoxListenerList`
`static java.lang.String` | `RB_KEY`
`protected int` | `selectedButton`
`protected boolean` | `showCustom`

Fields inherited from class com.sas.awt.Dialog
`_cantUseSASModal, _inApplet, _modal, autoDispose, READY, setVisibleCalled, t`

Constructor Summary
`ColorDialog(java.awt.Frame frame)` Construct a ColorDialog owned by a given Frame.
`ColorDialog(java.awt.Frame frame, boolean modal, boolean custom)` Construct a ColorDialog owned by a given Frame.

Method Summary
`void` | `actionPerformed(java.awt.event.ActionEvent evt)` actionPerformed handles ActionEvents from the buttons in the ColorDialog.
`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 ColorDialog to return the button selected.
`java.awt.Color` | `getSelectedColor()` Returns the color created
`protected java.lang.String` | `paramString()` paramString returns information about the ColorDialog in String format.
`void` | `removeMessageBoxListener(MessageBoxListener listener)` This is part of the MessageBox interface implementation.
`void` | `setSelectedColor(java.awt.Color cl)` Set the color
`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

### cp

    protected ColorPanel cp

### buttonOK

    protected Button buttonOK

### buttonCancel

    protected Button buttonCancel

### buttonAdd

    protected Button buttonAdd

### showCustom

    protected boolean showCustom

### messageBoxListenerList

    protected MessageBoxListenerList messageBoxListenerList

Constructor Detail

### ColorDialog

    public ColorDialog(java.awt.Frame frame)

  Construct a ColorDialog owned by a given Frame. The ColorDialog will have a title of "Color", and be non-modal.

  Parameters:
    `frame` - The frame to own the ColorDialog.

### ColorDialog

    public ColorDialog(java.awt.Frame frame,
                       boolean modal,
                       boolean custom)

  Construct a ColorDialog owned by a given Frame.

  Parameters:
    `frame` - The frame to own the ColorDialog.
    `modal` - Whether the ColorDialog is modal.
    `custom` - Whether to display custom color information

Method Detail

### getExtendedBeanInfo

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

### actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent evt)

  actionPerformed handles ActionEvents from the buttons in the ColorDialog. 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`

### commonInit

    protected void commonInit()

  commonInit performs all the common functionality between the constructors of the FontDialog. It creates all the controls in the ColorDialog.

### getSelectedButton

    public int getSelectedButton()

  getSelectedButton can be called on the ColorDialog 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 ColorDialog and do not want to listen for MessageBoxEvents. When using this method with a modal ColorDialog, you can call it after the show() method.

### getSelectedColor

    public java.awt.Color getSelectedColor()

  Returns the color created

  Returns:
    color

### paramString

    protected java.lang.String paramString()

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

  Overrides:
    `paramString` in class `java.awt.Dialog`

### setSelectedColor

    public void setSelectedColor(java.awt.Color cl)

  Set the color

  Parameters:
    `cl` - the selected Color

### 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 ColorDialog 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)`

### 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

### 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)`

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.