com.metamatrix.toolbox.ui.widget
Class DialogWindow

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by com.metamatrix.toolbox.ui.widget.DialogWindow
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants
Direct Known Subclasses:
AboutDialog

public class DialogWindow
extends javax.swing.JDialog

This class is intended to be used everywhere within the application that a dialog needs to be displayed. It may only be used with a DialogPanel, which must be specified in the constructor. By default, this class acts as the controller for the accept and cancel buttons within the contained DialogPanel. The default action for each of these buttons is to dispose the dialog.

Since:
2.0
Version:
2.0
Author:
John P. A. Verhaeg
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static boolean IS_MODAL
           
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
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
DialogWindow(java.awt.Dialog owner, java.lang.String title, DialogPanel panel)
          Creates a modal dialog with the specified title, that will be displayed by the specified dialog.
DialogWindow(java.awt.Dialog owner, java.lang.String title, DialogPanel panel, boolean isModal)
          Creates a dialog with the specified title and modality, that will be displayed by the specified dialog.
DialogWindow(java.awt.Frame owner, java.lang.String title, DialogPanel panel)
          Creates a modal dialog with the specified title, that will be displayed by the specified frame.
DialogWindow(java.awt.Frame owner, java.lang.String title, DialogPanel panel, boolean isModal)
          Creates a dialog with the specified title and modality, that will be displayed by the specified frame.
 
Method Summary
protected  void accept(java.awt.event.ActionEvent event)
          Called when the user activates the accept button.
protected  void cancel(java.awt.AWTEvent event)
          Called when the user activates the cancel button or cancels the dialog via the title bar close button (with the 'X' icon) or the title bar system menu 'Close' option.
static void disposeConditionally(java.awt.Window window, java.awt.AWTEvent event)
          Disposes the specified window as long as the specified event is not a WidgetActionEvent or has not been destroyed.
 DialogPanel getDialogPanel()
           
protected static java.awt.Dimension getDimensionFromPreferences(java.lang.String propertyName)
           
static DialogWindow getInstance(java.awt.Component parent, java.lang.String title, java.awt.Component content)
           
protected  void initializeDialogWindow()
          Initializes the dialog: Adds the dlgPanel to the center of the dialog Centers dialog relative to its owner Adds listeners to the DialogPanel's accept and cancel buttons that call the accept and cancel methods, respectively, within this class Ties window close button ('X' button) to the cancel button's action
protected  void processWindowEvent(java.awt.event.WindowEvent event)
          Overridden to call the cancel() method in the event that the user cancels the window via its close button (the 'X' icon) or the 'Close' option in the system menu.
static void setSizeToPreferences(boolean flag)
           
static DialogPanel show(java.awt.Component parent, java.lang.String title, java.awt.Component content)
           
static DialogPanel show(DialogWindow dialog)
           
protected static void storeDimensionFromPreferences(java.lang.String propertyName, java.awt.Dimension size)
           
protected  void unregisterListeners()
          Unregisters the listeners for the accept and cancel buttons that callback to the contained DialogPanel to determine if the this dialog may be disposed.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, 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, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IS_MODAL

public static final boolean IS_MODAL
See Also:
Constant Field Values
Constructor Detail

DialogWindow

public DialogWindow(java.awt.Frame owner,
                    java.lang.String title,
                    DialogPanel panel)
Creates a modal dialog with the specified title, that will be displayed by the specified frame.

Parameters:
owner - The window that displayed the dialog
title - The dialog's title
panel - The contained DialogPanel
Since:
2.0

DialogWindow

public DialogWindow(java.awt.Dialog owner,
                    java.lang.String title,
                    DialogPanel panel)
Creates a modal dialog with the specified title, that will be displayed by the specified dialog.

Parameters:
owner - The window that displayed the dialog
title - The dialog's title
panel - The contained DialogPanel
Since:
2.0

DialogWindow

public DialogWindow(java.awt.Frame owner,
                    java.lang.String title,
                    DialogPanel panel,
                    boolean isModal)
Creates a dialog with the specified title and modality, that will be displayed by the specified frame.

Parameters:
owner - The window that displayed the dialog
title - The dialog's title
panel - The contained DialogPanel
isModal - Indicates whether the dialog is modal
Since:
2.0

DialogWindow

public DialogWindow(java.awt.Dialog owner,
                    java.lang.String title,
                    DialogPanel panel,
                    boolean isModal)
Creates a dialog with the specified title and modality, that will be displayed by the specified dialog.

Parameters:
owner - The window that displayed the dialog
title - The dialog's title
panel - The contained DialogPanel
isModal - Indicates whether the dialog is modal
Since:
2.0
Method Detail

disposeConditionally

public static void disposeConditionally(java.awt.Window window,
                                        java.awt.AWTEvent event)
Disposes the specified window as long as the specified event is not a WidgetActionEvent or has not been destroyed. In the latter case, the method will wait until the WidgetActionEvent is finished processing.

Parameters:
window - The window to be disposed
event - The event triggering the window's disposal
Since:
2.0

getDimensionFromPreferences

protected static java.awt.Dimension getDimensionFromPreferences(java.lang.String propertyName)
Since:
3.0

getInstance

public static DialogWindow getInstance(java.awt.Component parent,
                                       java.lang.String title,
                                       java.awt.Component content)
Since:
2.0

setSizeToPreferences

public static void setSizeToPreferences(boolean flag)
Since:
3.0

show

public static DialogPanel show(DialogWindow dialog)
Since:
2.0

show

public static DialogPanel show(java.awt.Component parent,
                               java.lang.String title,
                               java.awt.Component content)
Since:
2.0

storeDimensionFromPreferences

protected static void storeDimensionFromPreferences(java.lang.String propertyName,
                                                    java.awt.Dimension size)
Since:
3.0

accept

protected void accept(java.awt.event.ActionEvent event)
Called when the user activates the accept button. Simply disposes the dialog by default.

Parameters:
event - The WidgetActionEvent generated from activating the button
Since:
2.0

cancel

protected void cancel(java.awt.AWTEvent event)
Called when the user activates the cancel button or cancels the dialog via the title bar close button (with the 'X' icon) or the title bar system menu 'Close' option. Simply disposes the dialog by default.

Parameters:
event - The WidgetActionEvent generated from activating the button or closing the window
Since:
2.0

getDialogPanel

public DialogPanel getDialogPanel()
Returns:
The contained DialogPanel
Since:
2.0

initializeDialogWindow

protected void initializeDialogWindow()
Initializes the dialog:
  1. Adds the dlgPanel to the center of the dialog
  2. Centers dialog relative to its owner
  3. Adds listeners to the DialogPanel's accept and cancel buttons that call the accept and cancel methods, respectively, within this class
  4. Ties window close button ('X' button) to the cancel button's action

Since:
2.0

processWindowEvent

protected void processWindowEvent(java.awt.event.WindowEvent event)
Overridden to call the cancel() method in the event that the user cancels the window via its close button (the 'X' icon) or the 'Close' option in the system menu.

Overrides:
processWindowEvent in class javax.swing.JDialog
Parameters:
event - The window event to be processed
Since:
2.0

unregisterListeners

protected void unregisterListeners()
Unregisters the listeners for the accept and cancel buttons that callback to the contained DialogPanel to determine if the this dialog may be disposed.

Since:
3.1


Copyright © 2009. All Rights Reserved.