org.tigris.swidgets

Class Dialog

Implemented Interfaces:
ActionListener

public abstract class Dialog
extends JDialog
implements ActionListener

Base class for all dialogs, setting borders and component spacing.
Authors:
Bob Tarling
Jeremy Jones

Field Summary

static int
CLOSE_OPTION
Option type: CLOSE_OPTION
static int
DEFAULT_OPTION
Option type: DEFAULT_OPTION
static int
OK_CANCEL_HELP_OPTION
Option type: OK_CANCEL_HELP_OPTION
static int
OK_CANCEL_OPTION
Option type: OK_CANCEL_OPTION
static int
YES_NO_CANCEL_HELP_OPTION
Option type: YES_NO_CANCEL_HELP_OPTION
static int
YES_NO_CANCEL_OPTION
Option type: YES_NO_CANCEL_OPTION
static int
YES_NO_HELP_OPTION
Option type: YES_NO_HELP_OPTION
static int
YES_NO_OPTION
Option type: YES_NO_OPTION

Constructor Summary

Dialog(Frame owner, String title, boolean modal)
Creates a new Dialog with no content component.
Dialog(Frame owner, String title, int theOptionType, boolean modal)
Creates a new Dialog with no content component, using the specified optionType to determine the set of available buttons.

Method Summary

void
actionPerformed(ActionEvent e)
Default implementation simply closes the dialog when any of the standard buttons is pressed except the Help button.
void
addButton(JButton button)
Adds a new button to the set of available option buttons on the dialog.
void
addButton(JButton button, int index)
Adds a new button to the set of available option buttons on the dialog.
protected JButton
getCancelButton()
protected JButton
getCloseButton()
protected int
getComponentGap()
JComponent
getContent()
Returns the main component that is displayed within the dialog.
protected JButton
getHelpButton()
protected int
getLabelGap()
protected JButton
getNoButton()
protected JButton
getOkButton()
protected JButton
getYesButton()
protected abstract void
nameButtons()
Subclasses may override this method to change the names and mnemonics of the various JButtons which appear at the bottom of the dialog.
void
setContent(JComponent theContent)
Sets the main component to be displayed within the dialog.

Field Details

CLOSE_OPTION

public static final int CLOSE_OPTION
Option type: CLOSE_OPTION
Field Value:
0

DEFAULT_OPTION

public static final int DEFAULT_OPTION
Option type: DEFAULT_OPTION
Field Value:
0

OK_CANCEL_HELP_OPTION

public static final int OK_CANCEL_HELP_OPTION
Option type: OK_CANCEL_HELP_OPTION
Field Value:
6

OK_CANCEL_OPTION

public static final int OK_CANCEL_OPTION
Option type: OK_CANCEL_OPTION
Field Value:
5

YES_NO_CANCEL_HELP_OPTION

public static final int YES_NO_CANCEL_HELP_OPTION
Option type: YES_NO_CANCEL_HELP_OPTION
Field Value:
4

YES_NO_CANCEL_OPTION

public static final int YES_NO_CANCEL_OPTION
Option type: YES_NO_CANCEL_OPTION
Field Value:
3

YES_NO_HELP_OPTION

public static final int YES_NO_HELP_OPTION
Option type: YES_NO_HELP_OPTION
Field Value:
2

YES_NO_OPTION

public static final int YES_NO_OPTION
Option type: YES_NO_OPTION
Field Value:
1

Constructor Details

Dialog

public Dialog(Frame owner,
              String title,
              boolean modal)
Creates a new Dialog with no content component. The default set of button(s) will be displayed. After creating the Dialog, call setContent() to configure the dialog before calling show() to display it.
Parameters:
owner - the owning Frame
title - the title String for the dialog
modal - true if the dialog is modal

Dialog

public Dialog(Frame owner,
              String title,
              int theOptionType,
              boolean modal)
Creates a new Dialog with no content component, using the specified optionType to determine the set of available buttons. After creating the Dialog, call setContent() to configure the dialog before calling show() to display it.
Parameters:
owner - the owning Frame
title - the title String for the dialog
theOptionType - defines which buttons will be available on the dialog
modal - true if the dialog is modal

Method Details

actionPerformed

public void actionPerformed(ActionEvent e)
Default implementation simply closes the dialog when any of the standard buttons is pressed except the Help button.
See Also:
java.awt.event.ActionListener.actionPerformed(java.awt.event.ActionEvent)

addButton

public void addButton(JButton button)
Adds a new button to the set of available option buttons on the dialog. The button will appear after the buttons specified by the optionType.
Parameters:
button - the button to add to the dialog.

addButton

public void addButton(JButton button,
                      int index)
Adds a new button to the set of available option buttons on the dialog. The button will appear at the specified index.
Parameters:
button - the button to add to the dialog.
index - index at which to insert new button (0 for first button)

getCancelButton

protected JButton getCancelButton()
Returns:
the requested button

getCloseButton

protected JButton getCloseButton()
Returns:
the requested button

getComponentGap

protected int getComponentGap()
Returns:
Returns the componentGap.

getContent

public JComponent getContent()
Returns the main component that is displayed within the dialog.
Returns:
main component displayed in dialog

getHelpButton

protected JButton getHelpButton()
Returns:
the requested button

getLabelGap

protected int getLabelGap()
Returns:
Returns the labelGap.

getNoButton

protected JButton getNoButton()
Returns:
the requested button

getOkButton

protected JButton getOkButton()
Returns:
the requested button

getYesButton

protected JButton getYesButton()
Returns:
the requested button

nameButtons

protected abstract void nameButtons()
Subclasses may override this method to change the names and mnemonics of the various JButtons which appear at the bottom of the dialog.

setContent

public final void setContent(JComponent theContent)
Sets the main component to be displayed within the dialog. Note: this method is final because it is most likely to be used in subclass constructors, and calling a class's overridable methods in its own constructor is not good practice.
Parameters:
theContent - main component to display in dialog