com.borland.primetime.ui
Class DefaultDialog

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--javax.swing.JDialog
                                |
                                +--com.borland.primetime.ui.DefaultDialog
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class DefaultDialog
extends javax.swing.JDialog

This helper class provides a variety of convenient mechanisms for creating a dialog including: auto-centering, frame finding, default button handling, and minimum size enforcement.

See Also:
Serialized Form

Inner Class Summary
protected  class DefaultDialog.ButtonLink
          This class is used to wire a JButton to an ActionListener.
 
Inner classes inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Inner classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
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, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DefaultDialog(java.awt.Component owner, java.lang.String title, boolean modal)
          Creates a new DefaultDialog instance that automatically determines its size basd on the size of its contents.
DefaultDialog(java.awt.Component owner, java.lang.String title, boolean modal, boolean autoSize)
          Creates a new DefaultDialog instance.
 
Method Summary
 void centerOnScreen()
          Center the dialog on the screen.
protected  javax.swing.JRootPane createRootPane()
          Create a special root pane that enforces the minimum size of the dialog if the constructor 'autoSize' parameter was set to true.
static java.awt.Frame findFrame(java.awt.Component component)
          Given a component in the UI hierarchy, search through the parentage to find the owning Frame.
 java.lang.String getBoundsAsString()
           
 boolean isAutoCenter()
          Returns the auto-centering state of the dialog (default is true).
 void setAutoCenter(boolean autoCenter)
          Changes the auto-centering state of the dialog (by default is 'true').
 void setBoundsAsString(java.lang.String location)
           
 void setCancelButton(javax.swing.JButton cancelButton)
          Set the button to press on the "cancel" action, and automatically wire it to the VK_ESCAPE key.
 void setDefaultButton(javax.swing.JButton defaultButton)
          Set the default button, ensure that no other buttons are default capable, and map the enter key to trigger the default action on JTextField instances.
 void setHelpButton(javax.swing.JButton helpButton)
          Set the button to press on the "help" action, and automatically wire it to the VK_F1 key.
 void show()
          Override to enforce any automatic centering on screen as requested.
static boolean showModalDialog(java.awt.Component owner, java.lang.String title, javax.swing.JComponent component, com.borland.primetime.help.HelpTopic helpTopic)
          Displays a standard dialog including OK, Cancel and Help buttons below a single user-supplied component.
static boolean showModalDialog(java.awt.Component owner, java.lang.String title, javax.swing.JComponent component, com.borland.primetime.help.HelpTopic helpTopic, DialogValidator validator)
          Displays a standard dialog including OK, Cancel and Help buttons below a single user-supplied component.
static void showSimpleModalDialog(java.awt.Component owner, java.lang.String title, javax.swing.JComponent component, com.borland.primetime.help.HelpTopic helpTopic)
          Displays a standard dialog including OK and Help buttons but no Cancel button below a single user-supplied component.
 
Methods inherited from class javax.swing.JDialog
addImpl, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setLocationRelativeTo, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, setModal, setResizable, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, finalize, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, 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, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultDialog

public DefaultDialog(java.awt.Component owner,
                     java.lang.String title,
                     boolean modal)

Creates a new DefaultDialog instance that automatically determines its size basd on the size of its contents. The caller is responsible for adding content to the dialog, and should call the methods setCancelButton, setDefaultButton, and/or setHelpButton as appropriate before showing the dialog.

Parameters:
owner - Any component on the owning frame or dialog
title - The dialog's title
modal - True to create a modal dialog, false otherwise

DefaultDialog

public DefaultDialog(java.awt.Component owner,
                     java.lang.String title,
                     boolean modal,
                     boolean autoSize)
Creates a new DefaultDialog instance. The caller is responsible for adding content to the dialog, and should call the methods setCancelButton, setDefaultButton, and/or setHelpButton as appropriate before showing the dialog.
Parameters:
owner - Any component on the owning frame or dialog
title - The dialog's title
modal - True to create a modal dialog, false otherwise
autoSize - True if the dialog determines its size based on the size of its contents, false if the size will be set explicitly.
Method Detail

getBoundsAsString

public java.lang.String getBoundsAsString()

setBoundsAsString

public void setBoundsAsString(java.lang.String location)

setAutoCenter

public void setAutoCenter(boolean autoCenter)
Changes the auto-centering state of the dialog (by default is 'true').
Parameters:
autoCenter - True for auto-centering, false for standard dialog behavior.

isAutoCenter

public boolean isAutoCenter()
Returns the auto-centering state of the dialog (default is true).
Returns:
True if the dialog will center itself when displayed, false otherwise.

centerOnScreen

public void centerOnScreen()
Center the dialog on the screen.

setDefaultButton

public void setDefaultButton(javax.swing.JButton defaultButton)
Set the default button, ensure that no other buttons are default capable, and map the enter key to trigger the default action on JTextField instances.
Parameters:
defaultButton - The default button.

setCancelButton

public void setCancelButton(javax.swing.JButton cancelButton)
Set the button to press on the "cancel" action, and automatically wire it to the VK_ESCAPE key.
Parameters:
cancelButton - The cancel button.

setHelpButton

public void setHelpButton(javax.swing.JButton helpButton)
Set the button to press on the "help" action, and automatically wire it to the VK_F1 key.
Parameters:
helpButton - The help button.

showModalDialog

public static boolean showModalDialog(java.awt.Component owner,
                                      java.lang.String title,
                                      javax.swing.JComponent component,
                                      com.borland.primetime.help.HelpTopic helpTopic)
Displays a standard dialog including OK, Cancel and Help buttons below a single user-supplied component. If the supplied component implements the DialogValidator interface it is used for validation. The dialog is automatically sized using pack().
Parameters:
frame - owner Any component on the owning frame or dialog
title - The caption displayed in the dialog's title bar
component - The contents of the dialog
helpTopic - The helpTopic to call for this dialog
Returns:
False if the dialog was canceled.

showModalDialog

public static boolean showModalDialog(java.awt.Component owner,
                                      java.lang.String title,
                                      javax.swing.JComponent component,
                                      com.borland.primetime.help.HelpTopic helpTopic,
                                      DialogValidator validator)
Displays a standard dialog including OK, Cancel and Help buttons below a single user-supplied component. The dialog is automatically sized using pack().
Parameters:
frame - owner Any component on the owning frame or dialog
title - The caption displayed in the dialog's title bar
component - The contents of the dialog
validator - An implementation of DialogValiator for validating the contents of the dialog, or null if no validation is needed
Returns:
False if the dialog was canceled.

showSimpleModalDialog

public static void showSimpleModalDialog(java.awt.Component owner,
                                         java.lang.String title,
                                         javax.swing.JComponent component,
                                         com.borland.primetime.help.HelpTopic helpTopic)
Displays a standard dialog including OK and Help buttons but no Cancel button below a single user-supplied component. The dialog is automatically sizedusing pack().
Parameters:
frame - owner Any component on the owning frame or dialog
title - The caption displayed in the dialog's title bar
component - The contents of the dialog
helpTopic - The helpTopic to call for this dialog

findFrame

public static java.awt.Frame findFrame(java.awt.Component component)
Given a component in the UI hierarchy, search through the parentage to find the owning Frame.
Parameters:
component - Starting component for find.
Returns:
Frame or null if none found.

createRootPane

protected javax.swing.JRootPane createRootPane()
Create a special root pane that enforces the minimum size of the dialog if the constructor 'autoSize' parameter was set to true.
Overrides:
createRootPane in class javax.swing.JDialog
Returns:
JRootPane created by this method.

show

public void show()
Override to enforce any automatic centering on screen as requested.
Overrides:
show in class java.awt.Dialog