jbcl.control Package
java.lang.Object +----java.awt.Component +----java.awt.Container +----java.awt.Window +----java.awt.Dialog +----javax.swing.JDialog +----com.borland.jbcl.control.ButtonDialog +----com.borland.jbcl.control.ColorChooserDialog +----com.borland.jbcl.control.ExceptionDialog +----com.borland.jbcl.control.FontChooserDialog +----com.borland.jbcl.control.MessageDialog +----com.borland.jbcl.control.StringInputDialog +----com.borland.jbcl.control.UserNamePasswordDialog
Variables Constructors Properties Methods Event Listeners
Implements ActionListener, KeyListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants
ButtonDialog
creates a button dialog box that displays a set of buttons. It provides a way to embed predefined buttons and button sets in message boxes and dialog boxes. The dialog classes extend ButtonDialog
.
To use ButtonDialog
, specify the buttons to add to the dialog box by setting the buttonSet
property.
Pre-defined button sets
Name of button set | Buttons in the button set |
OK_CANCEL | OK, Cancel |
YES_NO | Yes, No |
YES_NO_CANCEL | Yes, No, Cancel |
OK_CANCEL_APPLY | OK, Cancel, Apply |
APPLY_DONE | Apply, Done |
ALL | OK, Yes, No, Cancel, Help, Apply, Done |
The following buttons close the dialog:
buttonAlignment
property. The buttons will have default labels on them unless you specify your own using the labels
property.
The result
property determines what the result of clicking the specified button is. To disable a button, call the enableButton()
button, passing it a boolean value of false.
If the enterOK
property value is true, pressing the Enter key sends an OK command to the dialog.
The show()
method displays the dialog box. The value of the centered
property determines whether the dialog box is centered on screen.
The ButtonDialog
maintains an array of ButtonDescriptors
that holds the information about the set of buttons in the dialog. You can access a descriptor for a specific button using either the buttonFromCommand()
or buttonFromID()
methods.
protected transient ActionMulticaster actionMulticaster
public static final int ALL = OK | YES | NO | CANCEL | DONE | HELP | APPLY | NEXT | PREVIOUS | DETAILS
public static final int APPLY = 0x040
public static final String APPLY_COMMAND = "apply"
public static final int APPLY_DONE = APPLY | DONE
protected int buttonAlignment
protected ButtonDescriptor[] buttonDescriptors
protected Container buttonPanel
protected JPanel buttonPanelHolder
protected int buttonSet
public static final int CANCEL = 0x008
public static final String CANCEL_COMMAND = "cancel"
protected boolean centered
protected Component centerPanel
public static final int DETAILS = 0x200
public static final String DETAILS_COMMAND = "details"
public static final int DONE = 0x010
public static final String DONE_COMMAND = "done"
protected boolean enterOK
protected boolean escapeCancelDetermines whether pressing the Escape key causes the
ButtonDialog
to cancel any changes and close.
This variable's value is set using the escapeCancel
property.
public static final int HELP = 0x020
public static final String HELP_COMMAND = "help"
protected String[] labels
protected java.util.Hashtable listeningTo
public static final int NEXT = 0x080
public static final String NEXT_COMMAND = "next"
public static final int NO = 0x004
public static final String NO_COMMAND = "no"
public static final int NONE = 0x000
public static final String NONE_COMMAND = "none"
public static final int OK = 0x001
public static final int OK_CANCEL = OK | CANCEL
public static final int OK_CANCEL_APPLY = OK | CANCEL | APPLY
public static final String OK_COMMAND = "ok"
public static final int PREVIOUS = 0x100
public static final String PREVIOUS_COMMAND = "previous"
protected ButtonDescriptor result
public static final int YES = 0x002
public static final String YES_COMMAND = "yes"
public static final int YES_NO = YES | NO
public static final int YES_NO_CANCEL = YES | NO | CANCEL
protected ButtonDialog(Frame frame)
Constructs a ButtonDialog
.
Parameters:
frame
protected ButtonDialog(Frame frame, String title)Constructs a
ButtonDialog
.
Parameters:
frame
title
protected ButtonDialog(Frame frame, String title, boolean modal, Component centerPanel, Container buttonPanel, ButtonDescriptor[] buttonDescriptors)
Constructs a ButtonDialog
.
Parameters:
frame
title
modal
ButtonDialog
is modal or not. A modal dialog must be dismissed before using the rest of the program.
centerPanel
buttonPanel
buttonDescriptors
ButtonDescriptor
array for this ButtonDialog
.
public ButtonDialog(Frame frame, String title, Component centerPanel)Constructs a
ButtonDialog
.
Parameters:
frame
title
centerPanel
protected ButtonDialog(Frame frame, String title, Component centerPanel, int buttonSet)Constructs a
ButtonDialog
.
Parameters:
frame
title
centerPanel
buttonSet
public int getButtonAlignment() public void setButtonAlignment(int alignment)Determines the alignment of the buttons within the dialog box. Valid values for
alignment
are LEFT, CENTER, and RIGHT.
public int getButtonSet() public void setButtonSet(int bs)Defines the set of buttons to be displayed as a set of OR'ed button bits where
bs
is the set of button bits. For example,
setButtonSet(ButtonDialog.OK | ButtonDialog.CANCEL | ButtonDialog.HELP)
setButtonSet(ButtonDialog.OK_CANCEL)
public boolean isCentered() public void setCentered(boolean c)Determines whether the button dialog is centered on screen. If
centered
is true, the dialog is centered. The default value is true.
public Component getCenterPanel() public void setCenterPanel(Component panel)The center panel used for the button dialog.
public boolean isEnterOK() public void setEnterOK(boolean e)Determines whether pressing the Enter key generates an OK command. If
enterOK
is true, an OK command is generated when the Enter key is pressed. The default value is true.
public boolean isEscapeCancel() public void setEscapeCancel(boolean c)Determines whether pressing the Escape key generates a Cancel command. If
escapeCancel
is true, a Cancel command is generated when the Escape key is pressed. The default value is true.
public String[] getLabels() public void setLabels(String[] l)Specifies the labels for the set of buttons. If labels aren't provided, default labels are used. For example, the default label for the OK button is "OK".
You can specify labels for all buttons, or just for the visible buttons. The labels for the buttons are specified as an array of strings.
public Dimension getPreferredSize()Returns the preferred size of the dialog box. The preferred size will always be at least 300 pixels wide and 150 pixels high.
public int getResult() public void setResult(int id)Determines the button id value that is returned when the button is clicked. Valid constants for
id
are:
NONE, OK, YES, NO, CANCEL, DONE, HELP, APPLY, NEXT, PREVIOUS, and DETAILS.
protected void assureOnScreen()Displays the dialog box on screen if it is not already there.
public ButtonDescriptor buttonFromCommand(String actionCommand)Returns the
ButtonDescriptor
for the button identified by its command.
Parameters:
actionCommand
public ButtonDescriptor buttonFromID(int id)Returns the
ButtonDescriptor
for the button identified by the button ID.
Parameters:
id
protected static final ButtonDescriptor[] buttonSetToButtonDescriptors(int buttonSet)Creates a new array of
ButtonDescriptor
objects from the specified set of buttons.
Parameters:
buttonSet
buttonSet
property.
protected void centerOnScreen()Centers the dialog box on screen.
public void dispose()
Overrides: java.awt.Window.dispose()
protected void dropKeyListeners(Component comp)
public void enableButton(String actionCommand, boolean enableState)Enables and disables the specified button.
Parameters:
actionCommand
enableState
protected void listenForKeys(Component comp)Adds the specified component as a listener for key events in every child component.
protected void processActionEvent(ActionEvent e)Dispatches an action event to all listeners. Buttons that close the dialog can set the result to null to abort a button command.
Parameters:
e
protected void processWindowEvent(WindowEvent e)Process window events that the
ButtonDialog
receives.
Overrides: java.awt.Window.processWindowEvent(WindowEvent)
protected void setupButtonLabels()Adds the labels specified with the
labels
property to the array of ButtonDescriptor
objects. If the length of the labels
array is the same as the length of the ButtonDescriptors
array, the label strings are set for all the buttons; otherwise, they are set for just the visible buttons. setupButtonLabels()
is called by setLabels()
.
public void show()Displays the dialog on screen.
Overrides: java.awt.Dialog.show()
public synchronized void addActionListener(ActionListener l) public synchronized void removeActionListener(ActionListener l)
public synchronized void addComponentListener(java.awt.event.ComponentListener ) public synchronized void removeComponentListener(java.awt.event.ComponentListener )
public synchronized void addContainerListener(java.awt.event.ContainerListener ) public synchronized void removeContainerListener(java.awt.event.ContainerListener )
public synchronized void addFocusListener(java.awt.event.FocusListener ) public synchronized void removeFocusListener(java.awt.event.FocusListener )
public synchronized void addInputMethodListener(java.awt.event.InputMethodListener ) public synchronized void removeInputMethodListener(java.awt.event.InputMethodListener )
public synchronized void addKeyListener(java.awt.event.KeyListener ) public synchronized void removeKeyListener(java.awt.event.KeyListener )
public synchronized void addMouseListener(java.awt.event.MouseListener ) public synchronized void removeMouseListener(java.awt.event.MouseListener )
public synchronized void addMouseMotionListener(java.awt.event.MouseMotionListener ) public synchronized void removeMouseMotionListener(java.awt.event.MouseMotionListener )
public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener ) public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener )
public synchronized void addWindowListener(java.awt.event.WindowListener ) public synchronized void removeWindowListener(java.awt.event.WindowListener )