|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.visuals.ColorDialog
public class ColorDialog
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.
MessageBoxEvent
,
MessageBoxListener
,
MessageBoxSource
,
MessageBoxListenerList
,
Serialized FormField 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 interface com.sas.awt.ContainerInterface |
---|
getComponents, getLayout, invalidate, setLayout, validate |
Field Detail |
---|
public static final java.lang.String RB_KEY
public static final int BUTTON_OK
public static final int BUTTON_CANCEL
public static final int BUTTONS_OK_CANCEL
protected Button lastButtonWithFocus
protected int selectedButton
protected ColorPanel cp
protected Button buttonOK
protected Button buttonCancel
protected Button buttonAdd
protected boolean showCustom
protected MessageBoxListenerList messageBoxListenerList
Constructor Detail |
---|
public ColorDialog(java.awt.Frame frame)
frame
- The frame to own the ColorDialog.public ColorDialog(java.awt.Frame frame, boolean modal, boolean custom)
frame
- The frame to own the ColorDialog.modal
- Whether the ColorDialog is modal.custom
- Whether to display custom color informationMethod Detail |
---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed
in interface java.awt.event.ActionListener
protected void commonInit()
public int getSelectedButton()
public java.awt.Color getSelectedColor()
protected java.lang.String paramString()
paramString
in class java.awt.Dialog
public void setSelectedColor(java.awt.Color cl)
cl
- the selected Colorpublic void setVisible(boolean visible)
setVisible
in interface VisualInterface
setVisible
in class Dialog
visible
- Whether the component should be visible.VisualInterface.setVisible(boolean)
public void windowOpened(java.awt.event.WindowEvent e)
windowOpened
in interface java.awt.event.WindowListener
windowOpened
in class Dialog
e
- windowEventpublic void windowClosing(java.awt.event.WindowEvent e)
When the window close button is clicked, a MessageEvent is sent with the button field as CANCEL and the window is hidden using dipose().
windowClosing
in interface java.awt.event.WindowListener
windowClosing
in class Dialog
e
- windowEventpublic void windowClosed(java.awt.event.WindowEvent e)
windowClosed
in interface java.awt.event.WindowListener
windowClosed
in class Dialog
e
- windowEventpublic void windowIconified(java.awt.event.WindowEvent e)
windowIconified
in interface java.awt.event.WindowListener
windowIconified
in class Dialog
e
- windowEventpublic void windowDeiconified(java.awt.event.WindowEvent e)
windowDeiconified
in interface java.awt.event.WindowListener
windowDeiconified
in class Dialog
e
- windowEventpublic void windowActivated(java.awt.event.WindowEvent e)
windowActivated
in interface java.awt.event.WindowListener
windowActivated
in class Dialog
e
- windowEventpublic void windowDeactivated(java.awt.event.WindowEvent e)
windowDeactivated
in interface java.awt.event.WindowListener
windowDeactivated
in class Dialog
e
- windowEventpublic void focusGained(java.awt.event.FocusEvent event)
focusGained
in interface java.awt.event.FocusListener
public void focusLost(java.awt.event.FocusEvent event)
focusLost
in interface java.awt.event.FocusListener
public void addMessageBoxListener(MessageBoxListener listener)
addMessageBoxListener
in interface MessageBoxSource
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.removeMessageBoxListener(com.sas.visuals.MessageBoxListener)
,
fireMessageBoxEvent(int)
public void removeMessageBoxListener(MessageBoxListener listener)
removeMessageBoxListener
in interface MessageBoxSource
listener
- an object which handles MessageBoxEvent eventsaddMessageBoxListener(com.sas.visuals.MessageBoxListener)
,
fireMessageBoxEvent(int)
public void fireMessageBoxEvent(int button)
addMessageBoxListener(com.sas.visuals.MessageBoxListener)
,
removeMessageBoxListener(com.sas.visuals.MessageBoxListener)
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |