borland Packages  Class Hierarchy  jbcl.control Package  Index 

ButtonDialog class

java.lang.Object
   +----java.awt.Component
           +----java.awt.Container
                   +----java.awt.Window
                           +----java.awt.Dialog
                                   +----borland.jbcl.control.ButtonDialog
                                           +----borland.jbcl.control.ColorChooserDialog
                                           +----borland.jbcl.control.FontChooserDialog
                                           +----borland.jbcl.control.MessageDialog
                                           +----borland.jbcl.control.ExceptionDialog
                                           +----borland.jbcl.control.StringInputDialog
                                           +----borland.jbcl.control.UserNamePasswordDialog

About the ButtonDialog class

Variables  Constructors  Properties  Methods  Event Listeners

Implements ActionListener, KeyListener, ImageObserver, MenuContainer, Serializable, EventListener

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 JBCL 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:

The remaining pre-defined buttons do not close the dialog: Specify how the buttons are aligned within the dialog using the 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.


ButtonDialog variables

Variables implemented in this class

Variables implemented in java.awt.Component

ButtonDialog constructors

ButtonDialog properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.awt.Component

Properties implemented in java.awt.Container

Properties implemented in java.awt.Dialog

Properties implemented in java.awt.Window

Properties implemented in java.lang.Object

ButtonDialog methods

Methods implemented in this class

Methods implemented in java.awt.Component

Methods implemented in java.awt.Container

Methods implemented in java.awt.Dialog

Methods implemented in java.awt.Window

Methods implemented in java.lang.Object

ButtonDialog event listeners


ButtonDialog variables

actionMulticaster

  protected transient ActionMulticaster actionMulticaster

ALL

  public static final int ALL = OK | YES | NO | CANCEL | DONE | HELP | APPLY | NEXT | PREVIOUS | DETAILS

APPLY

  public static final int APPLY = 0x040

APPLY_COMMAND

  public static final String APPLY_COMMAND = "apply"

APPLY_DONE

  public static final int APPLY_DONE = APPLY | DONE

buttonAlignment

  protected int buttonAlignment

buttonDescriptors

  protected ButtonDescriptor[] buttonDescriptors

buttonPanel

  protected Panel buttonPanel

buttonPanelHolder

  protected Panel buttonPanelHolder

buttonSet

  protected int buttonSet

CANCEL

  public static final int CANCEL = 0x008

CANCEL_COMMAND

  public static final String CANCEL_COMMAND = "cancel"

centered

  protected boolean centered

centerPanel

  protected Component centerPanel

DETAILS

  public static final int DETAILS = 0x200

DETAILS_COMMAND

  public static final String DETAILS_COMMAND = "details"

DONE

  public static final int DONE = 0x010

DONE_COMMAND

  public static final String DONE_COMMAND = "done"

enterOK

  protected boolean enterOK

escapeCancel

  protected boolean escapeCancel
Determines whether pressing the Escape key causes the ButtonDialog to cancel any changes and close. This variable's value is set using the escapeCancel property.

HELP

  public static final int HELP = 0x020

HELP_COMMAND

  public static final String HELP_COMMAND = "help"

labels

  protected String[] labels

NEXT

  public static final int NEXT = 0x080

NEXT_COMMAND

  public static final String NEXT_COMMAND = "next"

NO

  public static final int NO = 0x004

NO_COMMAND

  public static final String NO_COMMAND = "no"

NONE

  public static final int NONE = 0x000

NONE_COMMAND

  public static final String NONE_COMMAND = "none"

OK

  public static final int OK = 0x001

OK_CANCEL

  public static final int OK_CANCEL = OK | CANCEL

OK_CANCEL_APPLY

  public static final int OK_CANCEL_APPLY = OK | CANCEL | APPLY

OK_COMMAND

  public static final String OK_COMMAND = "ok"

PREVIOUS

  public static final int PREVIOUS = 0x100

PREVIOUS_COMMAND

  public static final String PREVIOUS_COMMAND = "previous"

result

  protected ButtonDescriptor result

YES

  public static final int YES = 0x002

YES_COMMAND

  public static final String YES_COMMAND = "yes"

YES_NO

  public static final int YES_NO = YES | NO

YES_NO_CANCEL

  public static final int YES_NO_CANCEL = YES | NO | CANCEL

ButtonDialog constructors

ButtonDialog(java.awt.Frame)

  protected ButtonDialog(java.awt.Frame frame)

Constructs a ButtonDialog.

Parameters:

frame
The host frame for the dialog.

ButtonDialog(java.awt.Frame, java.lang.String)

  protected ButtonDialog(java.awt.Frame frame, java.lang.String title)
Constructs a ButtonDialog.

Parameters:

frame
The host frame for the dialog.
title
The text to display in the title bar of the dialog.

ButtonDialog(java.awt.Frame, java.lang.String, boolean, java.awt.Component, java.awt.Panel, borland.jbcl.control.ButtonDescriptor[])

  protected ButtonDialog(java.awt.Frame frame, java.lang.String title, boolean modal, java.awt.Component centerPanel, java.awt.Panel buttonPanel, borland.jbcl.control.ButtonDescriptor[] buttonDescriptors)
Constructs a ButtonDialog.

Parameters:

frame
The host frame for the dialog.
title
The text to display in the title bar of the dialog.
modal
If modal is true, the user must close the dialog before interacting with any other part of the user interface. If modal is false, the dialog can remain open while the user interfacts with other parts of the UI.
centerPanel
The component which the button set should be centered in, or centered relative to.
buttonPanel
The specific panel in which to place the button set.
buttonDescriptors
An array of button descriptor objects. A button descriptor stores the command, label, id, and closeDialog properties for a button.

ButtonDialog(java.awt.Frame, java.lang.String, java.awt.Component)

  public ButtonDialog(java.awt.Frame frame, java.lang.String title, java.awt.Component centerPanel)
Constructs a ButtonDialog.

Parameters:

frame
The host frame for the dialog.
title
The text to display in the title bar of the dialog.
centerPanel
The component which the button set should be centered in, or centered relative to.

ButtonDialog(java.awt.Frame, java.lang.String, java.awt.Component, int)

  protected ButtonDialog(java.awt.Frame frame, java.lang.String title, java.awt.Component centerPanel, int buttonSet)
Constructs a ButtonDialog.

Parameters:

frame
The host frame for the dialog.
title
The text to display in the title bar of the dialog.
centerPanel
The component which the button set should be centered in, or centered relative to.
buttonSet
The int constant to indicate a predefined button set to use. See the Pre-defined button sets table in the About section for this class.


ButtonDialog properties

buttonAlignment

 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.

buttonSet

 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,

centered

 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.

centerPanel

 public Component getCenterPanel()
 public void setCenterPanel(java.awt.Component panel)
The center panel used for the button dialog.

enterOK

 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.

escapeCancel

 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.

labels

 public String[] getLabels()
 public void setLabels(java.lang.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.

preferredSize

 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.

result

 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.

ButtonDialog methods

assureOnScreen()

  protected void assureOnScreen()
Displays the dialog box on screen if it is not already there.

buttonFromCommand(java.lang.String)

  public ButtonDescriptor buttonFromCommand(java.lang.String actionCommand)
Returns the ButtonDescriptor for the button identified by its command.

Parameters:

actionCommand
The command string that identifies a particular button. The possible values are NONE_COMMAND, OK_COMMAND, YES_COMMAND, NO_COMMAND, CANCEL_COMMAND, DONE_COMMAND, HELP_COMMAND, APPLY_COMMAND, NEXT_COMMAND, PREVIOUS_COMMAND, and DETAILS_COMMAND.

buttonFromID(int)

  public ButtonDescriptor buttonFromID(int id)
Returns the ButtonDescriptor for the button identified by the button ID.

Parameters:

id
The ID value that identifies a particular command. The possible values are the ID constants: OK, YES, NO, CANCEL, DONE, HELP, APPLY, NEXT, PREVIOUS, and DETAILS.

buttonSetToButtonDescriptors(int)

  protected static final ButtonDescriptor[] buttonSetToButtonDescriptors(int buttonSet)
Creates a new array of ButtonDescriptor objects from the specified set of buttons.

Parameters:

buttonSet
Defines the set of buttons to be displayed as a set of OR'ed button bits. See the buttonSet property.

centerOnScreen()

  protected void centerOnScreen()
Centers the dialog box on screen.

dropKeyListeners(java.awt.Component)

  protected void dropKeyListeners(java.awt.Component comp)

enableButton(java.lang.String, boolean)

  public void enableButton(java.lang.String actionCommand, boolean enableState)
Enables and disables the specified button.

Parameters:

actionCommand
description
enableState
If true, the button is enabled. If false, the button is disabled.

listenForKeys(java.awt.Component)

  protected void listenForKeys(java.awt.Component comp)
Adds the specified component as a listener for key events in every child component.

processActionEvent(java.awt.event.ActionEvent)

  protected void processActionEvent(java.awt.event.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
An action event object that is passed to listeners.

processWindowEvent(java.awt.event.WindowEvent)

  protected void processWindowEvent(java.awt.event.WindowEvent e)
Process window events that the ButtonDialog receives.

Overrides: java.awt.Window.processWindowEvent(WindowEvent)

setupButtonLabels()

  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().

show()

  public void show()
Displays the dialog on screen.

Overrides: java.awt.Dialog.show()


ButtonDialog event listeners

This class is a source for the following event sets. For information on the standard AWT event sets, see Standard Java events.

action

 public synchronized void addActionListener(java.awt.event.ActionListener l)
 public synchronized void removeActionListener(java.awt.event.ActionListener l)

component

 public synchronized void addComponentListener(java.awt.event.ComponentListener )
 public synchronized void removeComponentListener(java.awt.event.ComponentListener )

container

 public synchronized void addContainerListener(java.awt.event.ContainerListener )
 public void removeContainerListener(java.awt.event.ContainerListener )

focus

 public synchronized void addFocusListener(java.awt.event.FocusListener )
 public synchronized void removeFocusListener(java.awt.event.FocusListener )

key

 public synchronized void addKeyListener(java.awt.event.KeyListener )
 public synchronized void removeKeyListener(java.awt.event.KeyListener )

mouse

 public synchronized void addMouseListener(java.awt.event.MouseListener )
 public synchronized void removeMouseListener(java.awt.event.MouseListener )

mouseMotion

 public synchronized void addMouseMotionListener(java.awt.event.MouseMotionListener )
 public synchronized void removeMouseMotionListener(java.awt.event.MouseMotionListener )

window

 public synchronized void addWindowListener(java.awt.event.WindowListener )
 public synchronized void removeWindowListener(java.awt.event.WindowListener )