edu.neu.ccs.gui
Class GeneralDialog

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Dialog
                  extended byjavax.swing.JDialog
                      extended byedu.neu.ccs.gui.GeneralDialog
All Implemented Interfaces:
Accessible, ConsoleAware, ImageObserver, JPTConstants, MenuContainer, RootPaneContainer, Serializable, SwingConstants, WindowConstants
Direct Known Subclasses:
ColorPaneDialog

public class GeneralDialog
extends JDialog
implements JPTConstants, ConsoleAware

A dialog box containing a Component and an ActionsPanel that contains actions to respond to and dismiss the dialog.

As of 2.6.0, improved setBackground and added setDeepBackground in a manner similar to DisplayPanel.

Since:
2.0
Version:
2.6.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  ActionsPanel actionsPanel
          The actions panel with the user response buttons.
protected  boolean cancelled
          Whether or not this dialog was dismissed by cancellation.
protected  Component component
          The component displayed in this dialog.
protected  TablePanel contentPanel
          The content panel to combine the component and actions panel.
protected  Dialog parentDialog
          Parent Dialog if any.
protected  Frame parentFrame
          Parent Frame if any.
protected  String response
          User response to this dialog.
static String WINDOW_CLOSED
          Response returned by the default dialog window closing action.
protected  WindowActionAdapter windowActionAdapter
          Window action adapter for this dialog.
protected  DialogAction windowClosingAction
          Window closing action for this dialog.
protected  Action windowOpenedAction
          Window opened action for this dialog.
protected  DisplayPanel wrapperPanel
          The wrapper panel to ensure that the content panel is centered.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
 
Fields inherited from class java.awt.Window
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface edu.neu.ccs.util.JPTConstants
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface edu.neu.ccs.console.ConsoleAware
console
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GeneralDialog(Object displayObject)
          Constructs a modal general dialog containing the Component associated with the given display object, an empty dialog title, an empty ActionsPanel, and no parent window.
GeneralDialog(Object displayObject, String title)
          Constructs a modal general dialog containing the Component associated with the given display object, the given dialog title, an empty ActionsPanel, and no parent window.
GeneralDialog(Object displayObject, String title, Object[][] actionData)
          Constructs a modal general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, and no parent window.
GeneralDialog(Object displayObject, String title, Object[][] actionData, boolean modal)
          Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the given choice of whether or not the dialog is modal, and no parent window.
GeneralDialog(Object displayObject, String title, Object[][] actionData, boolean modal, Dialog parent)
          Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the given choice of whether or not the dialog is modal, and the given parent window.
GeneralDialog(Object displayObject, String title, Object[][] actionData, boolean modal, Frame parent)
          Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the given choice of whether or not the dialog is modal, and the given parent window.
GeneralDialog(Object displayObject, String title, Object[][] actionData, Object defaultAction)
          Constructs a modal general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the action for the default button, and no parent window.
GeneralDialog(Object displayObject, String title, Object[][] actionData, Object defaultAction, boolean modal)
          Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the action for the default button, the given choice of whether or not the dialog is modal, and no parent window.
GeneralDialog(Object displayObject, String title, Object[][] actionData, Object defaultAction, boolean modal, Dialog parent)
          Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the action for the default button, the given choice of whether or not the dialog is modal, and the given parent window.
GeneralDialog(Object displayObject, String title, Object[][] actionData, Object defaultAction, boolean modal, Frame parent)
          Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the action for the default button, the given choice of whether or not the dialog is modal, and the given parent window.
 
Method Summary
 JButton addAction(Action action, Object finish)
          Adds the given ordinary action with the given finish parameter to the actions panel for this dialog and returns the associated button.
 JButton addAction(DialogAction action)
          Adds the given dialog action to the actions panel for this dialog and returns the associated button.
 JButton addAction(String name, Icon icon, Object finish)
          Adds a trivial action with the given name, icon, and finish parameter to the actions panel for this dialog and returns the associated button.
 JButton addAction(String name, Object finish)
          Adds a trivial action with the given name and finish parameter to the actions panel for this dialog and returns the associated button.
 void center()
          Centers this dialog on the user screen or in its parent window.
protected  void closeDialog()
          Closes and disposes this dialog.
protected  void createContentPane()
          Creates the dialog content pane.
 Action[] getActions()
          Returns the Action objects in the actions panel for this dialog.
 DialogAction getDefaultWindowClosingAction()
          Returns the default dialog window closing action.
 DialogAction[] getDialogActions()
          Returns the DialogAction objects in the actions panel for this dialog.
 ActionsPanel getDialogActionsPanel()
          Returns the actions panel for this dialog.
 Component getDialogContents()
          Returns the main component in this dialog.
 String getResponse()
          Returns the user's response to this dialog.
 WindowActionAdapter getWindowActionAdapter()
          Returns the WindowActionAdapter for this dialog.
 DialogAction getWindowClosingAction()
          Returns the current dialog window closing action.
 Action getWindowOpenedAction()
          Returns the current dialog window opened action.
protected  void initializeGeneralDialog(Object displayObject, Object[][] actionData, Object defaultAction)
          Performs the common tasks required for constructors of this class using the given display object, action data, and default action.
protected  void installWindowActionAdapter()
          Installs the default window action adapter for this dialog using the default window closing action.
protected  Component makeComponent(Object o)
          Returns a Component for the given object constructed using the makeComponent method in ComponentFactory.
static GeneralDialog makeOKCancelDialog(Object displayObject, String title)
          Makes a GeneralDialog with the given display object and title and "OK" and a "Cancel" buttons with "OK" as the default.
static GeneralDialog makeOKDialog(Object displayObject, String title)
          Makes a GeneralDialog with the given display object and title and with an "OK" button that is the default button.
static GeneralDialog makeOneButtonDialog(Object displayObject, String title, Action action)
          Makes a GeneralDialog with the given display object and title and a single action button that is the default button.
static GeneralDialog makeOneButtonDialog(Object displayObject, String title, String name)
          Makes a GeneralDialog with the given display object and title and a single default button with the given name.
static GeneralDialog makeOneButtonDialog(Object displayObject, String title, String name, Icon icon)
          Makes a GeneralDialog with the given display object and title and a single default button with the given name and icon.
static GeneralDialog makeYesNoCancelDialog(Object displayObject, String title)
          Makes a GeneralDialog with the given display object and title and "Yes", "No", and "Cancel" buttons with "Yes" as the default.
 void setBackground(Color c)
          Overrides the inherited setBackground to set not only the background of the dialog itself but also the background of its top level entities.
protected  void setCancelled(boolean cancelled)
          Sets whether or not this dialog was cancelled.
 void setDeepBackground(Color c)
          Sets the background of this object to the given color; then sets the background of each component within this object to the same color using setDeepBackground recursively for each component that happens to extend DisplayPanel or JPTComponent.
 void setDeepBackground(Color c, Class type)
          Sets the background of all components in the hierarchy of this object that are instances of the given class.
 void setDefaultButton(Action action)
          Sets the button that corresponds to the given action as the default button for this dialog.
 void setDefaultButton(JButton button)
          Sets the given button as the default button for this dialog.
 void setDefaultButton(String name)
          Sets the button that corresponds to the given name as the default button for this dialog.
protected  void setResponseAndClose(String userResponse)
          Sets the user response String and closes this dialog.
 void setVisible(boolean makeVisible)
          Overrides the default setVisible behavior to automatically pack and center when the dialog is shown.
 void setWindowClosingAction(Action action, Object finish)
          Sets the dialog window closing action to a dialog action created from the given ordinary action and the given dialog finish parameter.
 void setWindowClosingAction(DialogAction action)
          Sets the dialog window closing action to the given dialog action.
 void setWindowClosingAction(String name, Object finish)
          Sets the dialog window closing action to a dialog action created with the given name and the given dialog finish parameter.
 void setWindowOpenedAction(Action action)
          Sets the dialog window opened action to the given action.
static String showOKCancelDialog(Object displayObject, String title)
          Shows a GeneralDialog with the given display object and title and "OK" and a "Cancel" buttons with "OK" as the default.
static String showOKDialog(Object displayObject, String title)
          Shows a GeneralDialog with the given display object and title and with an "OK" button that is the default button.
static String showOneButtonDialog(Object displayObject, String title, Action action)
          Shows a GeneralDialog with the given display object and title and a single action button that is the default button.
static String showOneButtonDialog(Object displayObject, String title, String name)
          Shows a GeneralDialog with the given display object and title and a single default button with the given name.
static String showOneButtonDialog(Object displayObject, String title, String name, Icon icon)
          Shows a GeneralDialog with the given display object and title and a single default button with the given name and icon.
static String showYesNoCancelDialog(Object displayObject, String title)
          Shows a GeneralDialog with the given display object and title and "Yes", "No", and "Cancel" buttons with "Yes" as the default.
 boolean wasCancelled()
          Returns whether or not this dialog was dismissed by cancellation.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WINDOW_CLOSED

public static final String WINDOW_CLOSED
Response returned by the default dialog window closing action.

See Also:
Constant Field Values

component

protected Component component
The component displayed in this dialog.


actionsPanel

protected ActionsPanel actionsPanel
The actions panel with the user response buttons.


contentPanel

protected TablePanel contentPanel
The content panel to combine the component and actions panel.


wrapperPanel

protected DisplayPanel wrapperPanel
The wrapper panel to ensure that the content panel is centered.


windowClosingAction

protected DialogAction windowClosingAction
Window closing action for this dialog.


windowOpenedAction

protected Action windowOpenedAction
Window opened action for this dialog.


windowActionAdapter

protected WindowActionAdapter windowActionAdapter
Window action adapter for this dialog.


parentFrame

protected Frame parentFrame
Parent Frame if any.


parentDialog

protected Dialog parentDialog
Parent Dialog if any.


response

protected String response
User response to this dialog.


cancelled

protected boolean cancelled
Whether or not this dialog was dismissed by cancellation.

Constructor Detail

GeneralDialog

public GeneralDialog(Object displayObject)

Constructs a modal general dialog containing the Component associated with the given display object, an empty dialog title, an empty ActionsPanel, and no parent window.

Other constructors:

If the given display object is null or has no associated Component, an empty JPanel will be added.

Parameters:
displayObject - the object to display in the dialog

GeneralDialog

public GeneralDialog(Object displayObject,
                     String title)

Constructs a modal general dialog containing the Component associated with the given display object, the given dialog title, an empty ActionsPanel, and no parent window.

If the given display object is null or has no associated Component, an empty JPanel will be added.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
See Also:
GeneralDialog(Object)

GeneralDialog

public GeneralDialog(Object displayObject,
                     String title,
                     Object[][] actionData)

Constructs a modal general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, and no parent window.

If the given display object is null or has no associated Component, an empty JPanel will be added.

The parameter actionData is an Object[][] array that specifies each dialog Action in one of the following ways:

If the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

All actions specified by the parameter actionData will be encapsulated as DialogAction objects.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
actionData - the array used to generate the dialog actions
See Also:
GeneralDialog(Object)

GeneralDialog

public GeneralDialog(Object displayObject,
                     String title,
                     Object[][] actionData,
                     boolean modal)

Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the given choice of whether or not the dialog is modal, and no parent window.

If the given display object is null or has no associated Component, an empty JPanel will be added.

The parameter actionData is an Object[][] array that specifies each dialog Action in one of the following ways:

If the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

All actions specified by the parameter actionData will be encapsulated as DialogAction objects.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
actionData - the array used to generate the dialog actions
modal - the choice of whether or not the dialog is modal
See Also:
GeneralDialog(Object)

GeneralDialog

public GeneralDialog(Object displayObject,
                     String title,
                     Object[][] actionData,
                     boolean modal,
                     Frame parent)

Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the given choice of whether or not the dialog is modal, and the given parent window.

If the given display object is null or has no associated Component, an empty JPanel will be added.

The parameter actionData is an Object[][] array that specifies each dialog Action in one of the following ways:

If the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

All actions specified by the parameter actionData will be encapsulated as DialogAction objects.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
actionData - the array used to generate the dialog actions
modal - the choice of whether or not the dialog is modal
parent - the parent window
See Also:
GeneralDialog(Object)

GeneralDialog

public GeneralDialog(Object displayObject,
                     String title,
                     Object[][] actionData,
                     boolean modal,
                     Dialog parent)

Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the given choice of whether or not the dialog is modal, and the given parent window.

If the given display object is null or has no associated Component, an empty JPanel will be added.

The parameter actionData is an Object[][] array that specifies each dialog Action in one of the following ways:

If the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

All actions specified by the parameter actionData will be encapsulated as DialogAction objects.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
actionData - the array used to generate the dialog actions
modal - the choice of whether or not the dialog is modal
parent - the parent window
See Also:
GeneralDialog(Object)

GeneralDialog

public GeneralDialog(Object displayObject,
                     String title,
                     Object[][] actionData,
                     Object defaultAction)

Constructs a modal general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the action for the default button, and no parent window.

If the given display object is null or has no associated Component, an empty JPanel will be added.

The parameter actionData is an Object[][] array that specifies each dialog Action in one of the following ways:

If the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

All actions specified by the parameter actionData will be encapsulated as DialogAction objects.

The Object supplied for the default action must either be an Action or a name that is supplied in the action data. If the parameter is null, no default action is set.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
actionData - the array used to generate the dialog actions
defaultAction - the default action
Since:
2.3.3
See Also:
GeneralDialog(Object)

GeneralDialog

public GeneralDialog(Object displayObject,
                     String title,
                     Object[][] actionData,
                     Object defaultAction,
                     boolean modal)

Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the action for the default button, the given choice of whether or not the dialog is modal, and no parent window.

If the given display object is null or has no associated Component, an empty JPanel will be added.

The parameter actionData is an Object[][] array that specifies each dialog Action in one of the following ways:

If the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

All actions specified by the parameter actionData will be encapsulated as DialogAction objects.

The Object supplied for the default action must either be an Action or a name that is supplied in the action data. If the parameter is null, no default action is set.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
actionData - the array used to generate the dialog actions
defaultAction - the default action
modal - the choice of whether or not the dialog is modal
Since:
2.3.3
See Also:
GeneralDialog(Object)

GeneralDialog

public GeneralDialog(Object displayObject,
                     String title,
                     Object[][] actionData,
                     Object defaultAction,
                     boolean modal,
                     Frame parent)

Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the action for the default button, the given choice of whether or not the dialog is modal, and the given parent window.

If the given display object is null or has no associated Component, an empty JPanel will be added.

The parameter actionData is an Object[][] array that specifies each dialog Action in one of the following ways:

If the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

All actions specified by the parameter actionData will be encapsulated as DialogAction objects.

The Object supplied for the default action must either be an Action or a name that is supplied in the action data. If the parameter is null, no default action is set.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
actionData - the array used to generate the dialog actions
defaultAction - the default action
modal - the choice of whether or not the dialog is modal
parent - the parent window
Since:
2.3.3
See Also:
GeneralDialog(Object)

GeneralDialog

public GeneralDialog(Object displayObject,
                     String title,
                     Object[][] actionData,
                     Object defaultAction,
                     boolean modal,
                     Dialog parent)

Constructs a general dialog containing the Component associated with the given display object, the given dialog title, an ActionsPanel constructed from the given action data, the action for the default button, the given choice of whether or not the dialog is modal, and the given parent window.

If the given display object is null or has no associated Component, an empty JPanel will be added.

The parameter actionData is an Object[][] array that specifies each dialog Action in one of the following ways:

If the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:

If the option parameter is not specified, it is taken to be DialogAction.AUTO_CLOSE.

All actions specified by the parameter actionData will be encapsulated as DialogAction objects.

The Object supplied for the default action must either be an Action or a name that is supplied in the action data. If the parameter is null, no default action is set.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
actionData - the array used to generate the dialog actions
defaultAction - the default action
modal - the choice of whether or not the dialog is modal
parent - the parent window
Since:
2.3.3
See Also:
GeneralDialog(Object)
Method Detail

setVisible

public void setVisible(boolean makeVisible)
Overrides the default setVisible behavior to automatically pack and center when the dialog is shown.

Parameters:
makeVisible - whether or not to make the dialog visible
See Also:
center()

center

public void center()
Centers this dialog on the user screen or in its parent window.

See Also:
setVisible(boolean)

setBackground

public void setBackground(Color c)

Overrides the inherited setBackground to set not only the background of the dialog itself but also the background of its top level entities.

This method is not recursive.


setDeepBackground

public void setDeepBackground(Color c)
Sets the background of this object to the given color; then sets the background of each component within this object to the same color using setDeepBackground recursively for each component that happens to extend DisplayPanel or JPTComponent.

Parameters:
c - the background color

setDeepBackground

public void setDeepBackground(Color c,
                              Class type)

Sets the background of all components in the hierarchy of this object that are instances of the given class.

The background of the object itself will be set only if it is an instance of the given class.

The hierarchy is determined recursively as entities in instances of either DisplayPanel or JPTComponent.

Parameters:
c - the background color
type - the class whose objects should change

getDialogContents

public Component getDialogContents()
Returns the main component in this dialog.

See Also:
getDialogActionsPanel()

getDialogActionsPanel

public ActionsPanel getDialogActionsPanel()
Returns the actions panel for this dialog.

See Also:
getDialogContents()

getActions

public Action[] getActions()
Returns the Action objects in the actions panel for this dialog.

See Also:
getDialogActions()

getDialogActions

public DialogAction[] getDialogActions()

Returns the DialogAction objects in the actions panel for this dialog.

Uses the same indexing as in the getActions method and returns null for those Action objects that are not DialogAction objects.

See Also:
getActions()

addAction

public JButton addAction(DialogAction action)
Adds the given dialog action to the actions panel for this dialog and returns the associated button.

Parameters:
action - the dialog action to add to the actions panel
See Also:
addAction(Action, Object), addAction(String, Object), addAction(String, Icon, Object)

addAction

public JButton addAction(Action action,
                         Object finish)

Adds the given ordinary action with the given finish parameter to the actions panel for this dialog and returns the associated button.

The finish parameter must be one of the following values:

The default if the finish parameter is null, or is not one of these values, is DialogAction.AUTO_CLOSE.

Parameters:
action - the ordinary action to add to the actions panel
finish - what to do to the dialog when the action is done
See Also:
addAction(DialogAction), addAction(String, Object), addAction(String, Icon, Object)

addAction

public JButton addAction(String name,
                         Object finish)

Adds a trivial action with the given name and finish parameter to the actions panel for this dialog and returns the associated button.

The finish parameter must be one of the following values:

The default if the finish parameter is null, or is not one of these values, is DialogAction.AUTO_CLOSE.

Parameters:
name - the name for a trivial action
finish - what to do to the dialog when the action is done
See Also:
addAction(DialogAction), addAction(Action, Object), addAction(String, Icon, Object)

addAction

public JButton addAction(String name,
                         Icon icon,
                         Object finish)

Adds a trivial action with the given name, icon, and finish parameter to the actions panel for this dialog and returns the associated button.

The finish parameter must be one of the following values:

The default if the finish parameter is null, or is not one of these values, is DialogAction.AUTO_CLOSE.

Parameters:
name - the name for a trivial action
icon - the icon for a trivial action
finish - what to do to the dialog when the action is done
See Also:
addAction(DialogAction), addAction(Action, Object), addAction(String, Object)

setDefaultButton

public void setDefaultButton(JButton button)
Sets the given button as the default button for this dialog. If the given button is not in this dialog, this method does nothing.

Parameters:
button - the button to set as the default button
See Also:
setDefaultButton(Action), setDefaultButton(String), ActionsPanel.setDefaultButton(JButton)

setDefaultButton

public void setDefaultButton(Action action)
Sets the button that corresponds to the given action as the default button for this dialog. If the given button is not in this dialog, this method does nothing.

Parameters:
action - the action whose button should be the default button
See Also:
setDefaultButton(JButton), setDefaultButton(String), ActionsPanel.setDefaultButton(Action)

setDefaultButton

public void setDefaultButton(String name)
Sets the button that corresponds to the given name as the default button for this dialog. If the given button is not in this dialog, this method does nothing.

Parameters:
name - the name whose button should be the default button
See Also:
setDefaultButton(JButton), setDefaultButton(Action), ActionsPanel.setDefaultButton(String)

getWindowOpenedAction

public Action getWindowOpenedAction()
Returns the current dialog window opened action.

See Also:
setWindowOpenedAction(Action)

setWindowOpenedAction

public void setWindowOpenedAction(Action action)
Sets the dialog window opened action to the given action.

Parameters:
action - the action to perform when the user opens the dialog
See Also:
getWindowOpenedAction()

getWindowClosingAction

public DialogAction getWindowClosingAction()
Returns the current dialog window closing action.

See Also:
getDefaultWindowClosingAction(), setWindowClosingAction(DialogAction), setWindowClosingAction(Action, Object), setWindowClosingAction(String, Object)

getDefaultWindowClosingAction

public DialogAction getDefaultWindowClosingAction()
Returns the default dialog window closing action. This action will close the dialog and set the dialog response to the value of the String WINDOW_CLOSED.

See Also:
getWindowClosingAction(), setWindowClosingAction(DialogAction), setWindowClosingAction(Action, Object), setWindowClosingAction(String, Object)

setWindowClosingAction

public void setWindowClosingAction(DialogAction action)
Sets the dialog window closing action to the given dialog action. If the given action is null then the default window closing action will be installed.

Parameters:
action - the action to perform if the user closes the dialog
See Also:
getWindowClosingAction(), getDefaultWindowClosingAction(), setWindowClosingAction(Action, Object), setWindowClosingAction(String, Object)

setWindowClosingAction

public void setWindowClosingAction(Action action,
                                   Object finish)

Sets the dialog window closing action to a dialog action created from the given ordinary action and the given dialog finish parameter.

The finish parameter must be one of the following values:

The default if the finish parameter is null, or is not one of these values, is DialogAction.AUTO_CLOSE.

Parameters:
action - the action to perform if the user closes the dialog
finish - what to do to the dialog when the action is done
See Also:
getWindowClosingAction(), getDefaultWindowClosingAction(), setWindowClosingAction(DialogAction), setWindowClosingAction(String, Object)

setWindowClosingAction

public void setWindowClosingAction(String name,
                                   Object finish)

Sets the dialog window closing action to a dialog action created with the given name and the given dialog finish parameter. The created action will do work.

The finish parameter must be one of the following values:

The default if the finish parameter is null, or is not one of these values, is DialogAction.AUTO_CLOSE.

Parameters:
name - the name for a trivial action
finish - what to do to the dialog when the action is done
See Also:
getWindowClosingAction(), getDefaultWindowClosingAction(), setWindowClosingAction(DialogAction), setWindowClosingAction(Action, Object)

getWindowActionAdapter

public WindowActionAdapter getWindowActionAdapter()
Returns the WindowActionAdapter for this dialog.


getResponse

public String getResponse()
Returns the user's response to this dialog. If this method is called before the dialog is closed then the return value is undefined.

See Also:
setResponseAndClose(String), closeDialog()

wasCancelled

public boolean wasCancelled()
Returns whether or not this dialog was dismissed by cancellation. If this method is called before the dialog has been dismissed, this method will return false.


makeOneButtonDialog

public static GeneralDialog makeOneButtonDialog(Object displayObject,
                                                String title,
                                                Action action)
Makes a GeneralDialog with the given display object and title and a single action button that is the default button. Closing the dialog window is equivalent to clicking the button.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
action - the action to install as a button
See Also:
makeOneButtonDialog(Object, String, Action), showOneButtonDialog(Object, String, Action), makeOneButtonDialog(Object, String, String), showOneButtonDialog(Object, String, String), makeOneButtonDialog(Object, String, String, Icon), showOneButtonDialog(Object, String, String, Icon), makeOKDialog(Object, String), showOKDialog(Object, String)

showOneButtonDialog

public static String showOneButtonDialog(Object displayObject,
                                         String title,
                                         Action action)
Shows a GeneralDialog with the given display object and title and a single action button that is the default button. Closing the dialog window is equivalent to clicking the button.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
action - the action to install as a button
See Also:
GeneralDialog(Object, String, Object[][]), makeOneButtonDialog(Object, String, Action), makeOneButtonDialog(Object, String, String), showOneButtonDialog(Object, String, String), makeOneButtonDialog(Object, String, String, Icon), showOneButtonDialog(Object, String, String, Icon), makeOKDialog(Object, String), showOKDialog(Object, String)

makeOneButtonDialog

public static GeneralDialog makeOneButtonDialog(Object displayObject,
                                                String title,
                                                String name)
Makes a GeneralDialog with the given display object and title and a single default button with the given name. Closing the dialog window is equivalent to clicking the button.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
name - the name to install on the button
See Also:
GeneralDialog(Object, String, Object[][]), makeOneButtonDialog(Object, String, Action), showOneButtonDialog(Object, String, Action), showOneButtonDialog(Object, String, String), makeOneButtonDialog(Object, String, String, Icon), showOneButtonDialog(Object, String, String, Icon), makeOKDialog(Object, String), showOKDialog(Object, String)

showOneButtonDialog

public static String showOneButtonDialog(Object displayObject,
                                         String title,
                                         String name)
Shows a GeneralDialog with the given display object and title and a single default button with the given name. Closing the dialog window is equivalent to clicking the button.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
name - the name to install on the button
See Also:
GeneralDialog(Object, String, Object[][]), makeOneButtonDialog(Object, String, Action), showOneButtonDialog(Object, String, Action), makeOneButtonDialog(Object, String, String), makeOneButtonDialog(Object, String, String, Icon), showOneButtonDialog(Object, String, String, Icon), makeOKDialog(Object, String), showOKDialog(Object, String)

makeOneButtonDialog

public static GeneralDialog makeOneButtonDialog(Object displayObject,
                                                String title,
                                                String name,
                                                Icon icon)
Makes a GeneralDialog with the given display object and title and a single default button with the given name and icon. Closing the dialog window is equivalent to clicking the button.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
name - the name to install on the button
icon - the icon to install on the button
See Also:
GeneralDialog(Object, String, Object[][]), makeOneButtonDialog(Object, String, Action), showOneButtonDialog(Object, String, Action), makeOneButtonDialog(Object, String, String), showOneButtonDialog(Object, String, String), showOneButtonDialog(Object, String, String, Icon), makeOKDialog(Object, String), showOKDialog(Object, String)

showOneButtonDialog

public static String showOneButtonDialog(Object displayObject,
                                         String title,
                                         String name,
                                         Icon icon)
Shows a GeneralDialog with the given display object and title and a single default button with the given name and icon. Closing the dialog window is equivalent to clicking the button.

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
name - the name to install on the button
icon - the icon to install on the button
See Also:
GeneralDialog(Object, String, Object[][]), makeOneButtonDialog(Object, String, Action), showOneButtonDialog(Object, String, Action), makeOneButtonDialog(Object, String, String), showOneButtonDialog(Object, String, String), makeOneButtonDialog(Object, String, String, Icon), makeOKDialog(Object, String), showOKDialog(Object, String)

makeOKDialog

public static GeneralDialog makeOKDialog(Object displayObject,
                                         String title)
Makes a GeneralDialog with the given display object and title and with an "OK" button that is the default button. Closing the dialog window is equivalent to clicking "OK".

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
See Also:
GeneralDialog(Object, String, Object[][]), makeOneButtonDialog(Object, String, Action), showOneButtonDialog(Object, String, Action), makeOneButtonDialog(Object, String, String), showOneButtonDialog(Object, String, String), makeOneButtonDialog(Object, String, String, Icon), showOneButtonDialog(Object, String, String, Icon), showOKDialog(Object, String)

showOKDialog

public static String showOKDialog(Object displayObject,
                                  String title)
Shows a GeneralDialog with the given display object and title and with an "OK" button that is the default button. Closing the dialog window is equivalent to clicking "OK".

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
See Also:
GeneralDialog(Object, String, Object[][]), makeOneButtonDialog(Object, String, Action), showOneButtonDialog(Object, String, Action), makeOneButtonDialog(Object, String, String), showOneButtonDialog(Object, String, String), makeOneButtonDialog(Object, String, String, Icon), showOneButtonDialog(Object, String, String, Icon), makeOKDialog(Object, String)

makeOKCancelDialog

public static GeneralDialog makeOKCancelDialog(Object displayObject,
                                               String title)
Makes a GeneralDialog with the given display object and title and "OK" and a "Cancel" buttons with "OK" as the default. Clicking "Cancel" will set the cancelled state of the dialog to true. Closing the dialog window is equivalent to clicking "Cancel".

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
See Also:
GeneralDialog(Object, String, Object[][]), showOKCancelDialog(Object, String)

showOKCancelDialog

public static String showOKCancelDialog(Object displayObject,
                                        String title)
                                 throws CancelledException
Shows a GeneralDialog with the given display object and title and "OK" and a "Cancel" buttons with "OK" as the default. Clicking "Cancel" will throw a CancelledException. Closing the dialog window is equivalent to clicking "Cancel".

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
Throws:
CancelledException
See Also:
GeneralDialog(Object, String, Object[][]), makeOKCancelDialog(Object, String)

makeYesNoCancelDialog

public static GeneralDialog makeYesNoCancelDialog(Object displayObject,
                                                  String title)
Makes a GeneralDialog with the given display object and title and "Yes", "No", and "Cancel" buttons with "Yes" as the default. Clicking "Cancel" will set the cancelled state of the dialog to true. Closing the dialog window is equivalent to clicking "Cancel".

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
See Also:
GeneralDialog(Object, String, Object[][]), showYesNoCancelDialog(Object, String)

showYesNoCancelDialog

public static String showYesNoCancelDialog(Object displayObject,
                                           String title)
                                    throws CancelledException
Shows a GeneralDialog with the given display object and title and "Yes", "No", and "Cancel" buttons with "Yes" as the default. Clicking "Cancel" will throw a CancelledException. Closing the dialog window is equivalent to clicking "Cancel".

Parameters:
displayObject - the object to display in the dialog
title - the title text for the dialog
Throws:
CancelledException
See Also:
GeneralDialog(Object, String, Object[][]), makeYesNoCancelDialog(Object, String)

initializeGeneralDialog

protected void initializeGeneralDialog(Object displayObject,
                                       Object[][] actionData,
                                       Object defaultAction)

Performs the common tasks required for constructors of this class using the given display object, action data, and default action.

The given displayObject parameter will be converted to a Component using the makeComponent method.

If the given display object is null or has no associated Component, an empty JPanel will be added.

The parameter actionData is an Object[][] array that specifies each Action in one of the following ways:

The option parameter must be one of the following values that will determine what is done to the dialog when the action is finished:

The default if the option is not specified is DialogAction.AUTO_CLOSE.

All actions specified by the parameter actionData will be encapsulated as DialogAction objects.

The Object supplied for the default action must either be an Action or a name that is supplied in the action data. If the parameter is null, no default action is set.

Parameters:
displayObject - the object to display in the dialog
actionData - the array used to generate the dialog actions
defaultAction - the default action

makeComponent

protected Component makeComponent(Object o)
Returns a Component for the given object constructed using the makeComponent method in ComponentFactory.


createContentPane

protected void createContentPane()
Creates the dialog content pane.


installWindowActionAdapter

protected void installWindowActionAdapter()
Installs the default window action adapter for this dialog using the default window closing action.

See Also:
getWindowClosingAction(), setWindowClosingAction(DialogAction), getDefaultWindowClosingAction()

setResponseAndClose

protected void setResponseAndClose(String userResponse)
Sets the user response String and closes this dialog. If the parameter userResponse is null then an empty String will be set as the user response.

Parameters:
userResponse - a String representing the user's choice
See Also:
getResponse(), closeDialog()

closeDialog

protected void closeDialog()
Closes and disposes this dialog.


setCancelled

protected void setCancelled(boolean cancelled)
Sets whether or not this dialog was cancelled.