com.bric.swing
Class DialogFooter

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.bric.swing.DialogFooter
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class DialogFooter
extends JPanel

This is a row of buttons, intended to be displayed at the bottom of a dialog. This class is strongly related to the com.bric.swing.QDialog project, although the DialogFooter can exist by itself.

On the left of a footer are controls that should apply to the dialog itself, such as "Help" button, or a "Reset Preferences" button. On the far right are buttons that should dismiss this dialog. They may be presented in different orders on different platforms based on the reverseButtonOrder boolean.

Buttons are also generally normalized, so the widths of buttons are equal.

This object will "latch onto" the RootPane that contains it. It is assumed two DialogFooters will not be contained in the same RootPane. It is also assumed the same DialogFooter will not be passed around to several different RootPanes.

Preset Options

This class has several OPTION constants to create specific buttons.

In each constant the first option is the default button unless you specify otherwise. The Apple Interface Guidelines advises: "The default button should be the button that represents the action that the user is most likely to perform if that action isn?t potentially dangerous."

The YES_NO options should be approached with special reluctance. Microsoft cautions, "Use Yes and No buttons only to respond to yes or no questions." This seems obvious enough, but Apple adds, "Button names should correspond to the action the user performs when pressing the button?for example, Erase, Save, or Delete." So instead of presenting a YES_NO dialog with the question "Do you want to continue?" a better dialog might provide the options "Cancel" and "Continue". In short: we as developers might tend to lazily use this option and phrase dialogs in such a way that yes/no options make sense, but in fact the commit buttons should be more descriptive.

Partly because of the need to avoid yes/no questions, DialogFooter introduces the dialog type: SAVE_DONT_SAVE_CANCEL_OPTION. This is mostly straightforward, but there is one catch: on Mac the buttons are reordered: "Save", "Cancel" and "Don't Save". This is to conform with standard Mac behavior. (Or, more specifically: because the Apple guidelines state that a button that can cause permanent data loss be as physically far from a "safe" button as possible.) On all other platforms the buttons are listed in the order "Save", "Don't Save" and "Cancel".

Also note the field reverseButtonOrder controls the order each option is presented in the dialog from left-to-right.

Platform Differences

These are based mostly on studying Apple and Vista interface guidelines.
  • On Mac, command-period acts like the escape key in dialogs.
  • On Mac the Help component is the standard Mac help icon. On other platforms the help component is a com.bric.swing.JLink.
  • By default button order is reversed on Macs compared to other platforms. See the DialogFooter.reverseButtonOrder field for details.
  • There is a static boolean to control whether button mnemonics should be universally activated. This was added because when studying Windows XP there seemed to be no fixed rules for whether to use mnemonics or not. (Some dialogs show them, some dialogs don't.) So I leave it to your discretion to activate them. I think this boolean should never be activated on Vista or Mac, but on XP and Linux flavors: that's up to you. (Remember using the alt key usually activates the mnemonics in most Java look-and-feels, so just because they aren't universally active doesn't mean you're hurting accessibility needs.)
  • See Also:
    Serialized Form

    Nested Class Summary
    static class DialogFooter.ClickAction
              This action calls button.doClick().
     
    Nested classes/interfaces inherited from class javax.swing.JPanel
    JPanel.AccessibleJPanel
     
    Nested classes/interfaces inherited from class javax.swing.JComponent
    JComponent.AccessibleJComponent
     
    Nested classes/interfaces inherited from class java.awt.Container
    Container.AccessibleAWTContainer
     
    Nested classes/interfaces inherited from class java.awt.Component
    Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
     
    Field Summary
    protected  boolean autoClose
               
    static int CANCEL_OPTION
              Used to indicate the user selected "Cancel" in a dialog.
    static Action closeDialogAndDisposeAction
              This action takes the Window associated with the source of this event, hides it, and then calls dispose() on it.
    protected  JButton defaultButton
               
    protected  JComponent[] dismissControls
               
    static int DONT_SAVE_OPTION
              Used to indicate the user selected "Don't Save" in a dialog.
    static int ESCAPE_KEY_DOES_NOTHING
              This (the default behavior) does nothing when the escape key is pressed.
    static int ESCAPE_KEY_TRIGGERS_CANCEL
              This triggers the cancel button when the escape key is pressed.
    static int ESCAPE_KEY_TRIGGERS_DEFAULT
              This triggers the default button when the escape key is pressed.
    static int ESCAPE_KEY_TRIGGERS_NONDEFAULT
              This triggers the non-default button when the escape key is pressed.
    static boolean isMac
               
    static boolean isVista
               
    protected  JComponent lastSelectedComponent
               
    protected  JComponent[] leftControls
               
    static int NO_OPTION
              Used to indicate the user selected "No" in a dialog.
    static int OK_CANCEL_OPTION
              Used to indicate a dialog should present a "OK" and "Cancel" option.
    static int OK_OPTION
              Used to indicate the user selected "OK" in a dialog.
    static String PROPERTY_META_SHORTCUT
              This client property is used to impose a meta-shortcut to click a button.
    static String PROPERTY_OPTION
              This is the client property of buttons created in static methods by this class.
    static String PROPERTY_UNSAFE
              This client property is used to indicate a button is "unsafe".
    static boolean reverseButtonOrder
              This indicates whether the dismiss controls should be displayed in reverse order.
    static int SAVE_DONT_SAVE_CANCEL_OPTION
              Used to indicate a dialog should present a "Save", "Don't Save", and "Cancel" option.
    static int SAVE_OPTION
              Used to indicate the user selected "Save" in a dialog.
    static ResourceBundle strings
              The localized strings used in dialogs.
    static int YES_NO_CANCEL_OPTION
              Used to indicate a dialog should present a "Yes", "No", and "Cancel" option.
    static int YES_NO_OPTION
              Used to indicate a dialog should present a "Yes" and "No" option.
    static int YES_OPTION
              Used to indicate the user selected "Yes" in a dialog.
     
    Fields inherited from class javax.swing.JComponent
    accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
     
    Fields inherited from class java.awt.Component
    BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
     
    Fields inherited from interface java.awt.image.ImageObserver
    ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
     
    Constructor Summary
    DialogFooter(JComponent[] leftControls, JComponent[] dismissControls, boolean autoClose, JButton defaultButton)
              Create a new DialogFooter.
     
    Method Summary
     void addActionListener(ActionListener l)
              Adds an ActionListener.
    static JButton createCancelButton(boolean escapeKeyIsTrigger)
              Creates a new "Cancel" button.
    static DialogFooter createDialogFooter(JComponent[] leftComponents, int options, int escapeKeyBehavior)
              Creates a DialogFooter and assigns a default button.
    static DialogFooter createDialogFooter(JComponent[] leftComponents, int options, int defaultButton, int escapeKeyBehavior)
              Creates a DialogFooter.
    static JButton createDontSaveButton()
              Creates a new "Don't Save" button that is not triggered by the escape key.
    static JButton createDontSaveButton(boolean escapeKeyIsTrigger)
              Creates a new "Don't Save" button.
    static JButton createNoButton()
              Creates a new "No" button that is not triggered by the escape key.
    static JButton createNoButton(boolean escapeKeyIsTrigger)
              Creates a new "No" button.
    static JButton createOKButton()
              Creates a new "OK" button that is not triggered by the escape key.
    static JButton createOKButton(boolean escapeKeyIsTrigger)
              Creates a new "OK" button.
    static JButton createSaveButton()
              Creates a new "Save" button that is not triggered by the escape key.
    static JButton createSaveButton(boolean escapeKeyIsTrigger)
              Creates a new "Save" button.
    static JButton createYesButton()
              Creates a new "Yes" button that is not triggered by the escape key.
    static JButton createYesButton(boolean escapeKeyIsTrigger)
              Creates a new "Yes" button.
     JButton getButton(int buttonType)
              Finds a certain type of button, if it is available.
     JComponent[] getDismissControls()
              Returns a copy of the dismissControls array used to construct this footer.
     JComponent getLastSelectedComponent()
              Returns the component last used to dismiss the dialog.
     JComponent[] getLeftControls()
              Returns a copy of the leftControls array used to construct this footer.
    static void makeEscapeKeyActivate(AbstractButton button)
              This guarantees that when the escape key is pressed (if its parent window has the keyboard focus) this button is clicked.
    static void normalizeButtons(JButton[] buttons)
              This takes a set of buttons and gives them all the width/height of the largest button among them.
     void removeActionListener(ActionListener l)
              Removes an ActionListener.
     void reset()
              This resets the value of lastSelectedComponent to null.
     
    Methods inherited from class javax.swing.JPanel
    getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
     
    Methods inherited from class javax.swing.JComponent
    addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
     
    Methods inherited from class java.awt.Container
    add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    ESCAPE_KEY_DOES_NOTHING

    public static final int ESCAPE_KEY_DOES_NOTHING
    This (the default behavior) does nothing when the escape key is pressed.

    See Also:
    Constant Field Values

    ESCAPE_KEY_TRIGGERS_CANCEL

    public static final int ESCAPE_KEY_TRIGGERS_CANCEL
    This triggers the cancel button when the escape key is pressed. If no cancel button is present: this does nothing. (Also on Macs command+period acts the same as the escape key.)

    This should only be used if the cancel button does not lead to data loss, because users may quickly press the escape key before reading the text in a dialog.

    See Also:
    Constant Field Values

    ESCAPE_KEY_TRIGGERS_DEFAULT

    public static final int ESCAPE_KEY_TRIGGERS_DEFAULT
    This triggers the default button when the escape key is pressed. If no default button is defined: this does nothing. (Also on Macs command+period acts the same as the escape key.)

    This should only be used if the default button does not lead to data loss, because users may quickly press the escape key before reading the text in a dialog.

    See Also:
    Constant Field Values

    ESCAPE_KEY_TRIGGERS_NONDEFAULT

    public static final int ESCAPE_KEY_TRIGGERS_NONDEFAULT
    This triggers the non-default button when the escape key is pressed. If no non-default button is defined: this does nothing. (Also on Macs command+period acts the same as the escape key.)

    This should only be used if the non-default button does not lead to data loss, because users may quickly press the escape key before reading the text in a dialog.

    See Also:
    Constant Field Values

    strings

    public static ResourceBundle strings
    The localized strings used in dialogs.


    PROPERTY_OPTION

    public static String PROPERTY_OPTION
    This is the client property of buttons created in static methods by this class.


    CANCEL_OPTION

    public static final int CANCEL_OPTION
    Used to indicate the user selected "Cancel" in a dialog.
    Also this can be used as a dialog type, to indicate that "Cancel" should be the only option presented to the user.

    Note the usage is similar to JOptionPane's, but the numerical value is different, so you cannot substitute JOptionPane.CANCEL_OPTION for DialogFooter.CANCEL_OPTION.


    OK_OPTION

    public static final int OK_OPTION
    Used to indicate the user selected "OK" in a dialog.
    Also this can be used as a dialog type, to indicate that "OK" should be the only option presented to the user.

    Note the usage is similar to JOptionPane's, but the numerical value is different, so you cannot substitute JOptionPane.OK_OPTION for DialogFooter.OK_OPTION.


    NO_OPTION

    public static final int NO_OPTION
    Used to indicate the user selected "No" in a dialog.
    Also this can be used as a dialog type, to indicate that "No" should be the only option presented to the user.

    Note the usage is similar to JOptionPane's, but the numerical value is different, so you cannot substitute JOptionPane.NO_OPTION for DialogFooter.NO_OPTION.


    YES_OPTION

    public static final int YES_OPTION
    Used to indicate the user selected "Yes" in a dialog.
    Also this can be used as a dialog type, to indicate that "Yes" should be the only option presented to the user.

    Note the usage is similar to JOptionPane's, but the numerical value is different, so you cannot substitute JOptionPane.YES_OPTION for DialogFooter.YES_OPTION.


    YES_NO_OPTION

    public static final int YES_NO_OPTION
    Used to indicate a dialog should present a "Yes" and "No" option.

    Note the usage is similar to JOptionPane's, but the numerical value is different, so you cannot substitute JOptionPane.YES_NO_OPTION for DialogFooter.YES_NO_OPTION.


    YES_NO_CANCEL_OPTION

    public static final int YES_NO_CANCEL_OPTION
    Used to indicate a dialog should present a "Yes", "No", and "Cancel" option.

    Note the usage is similar to JOptionPane's, but the numerical value is different, so you cannot substitute JOptionPane.YES_NO_CANCEL_OPTION for DialogFooter.YES_NO_CANCEL_OPTION.


    OK_CANCEL_OPTION

    public static final int OK_CANCEL_OPTION
    Used to indicate a dialog should present a "OK" and "Cancel" option.

    Note the usage is similar to JOptionPane's, but the numerical value is different, so you cannot substitute JOptionPane.OK_CANCEL_OPTION for DialogFooter.OK_CANCEL_OPTION.


    SAVE_DONT_SAVE_CANCEL_OPTION

    public static final int SAVE_DONT_SAVE_CANCEL_OPTION
    Used to indicate a dialog should present a "Save", "Don't Save", and "Cancel" option.


    SAVE_OPTION

    public static final int SAVE_OPTION
    Used to indicate the user selected "Save" in a dialog.
    Also this can be used as a dialog type, to indicate that "Save" should be the only option presented to the user.


    DONT_SAVE_OPTION

    public static final int DONT_SAVE_OPTION
    Used to indicate the user selected "Don't Save" in a dialog.
    Also this can be used as a dialog type, to indicate that "Don't Save" should be the only option presented to the user.


    isMac

    public static final boolean isMac

    isVista

    public static final boolean isVista

    PROPERTY_META_SHORTCUT

    public static final String PROPERTY_META_SHORTCUT
    This client property is used to impose a meta-shortcut to click a button. This should map to a Character.

    See Also:
    Constant Field Values

    PROPERTY_UNSAFE

    public static final String PROPERTY_UNSAFE
    This client property is used to indicate a button is "unsafe". Apple guidelines state that "unsafe" buttons (such as "discard changes") should be several pixels away from "safe" buttons.

    See Also:
    Constant Field Values

    reverseButtonOrder

    public static boolean reverseButtonOrder
    This indicates whether the dismiss controls should be displayed in reverse order. When you construct a DialogFooter, the dismiss controls should be listed in order of priority (with the most preferred listed first, the least preferred last). If this boolean is false, then those components will be listed in that order. If this is true, then those components will be listed in the reverse order.

    By default on Mac this is true, because Macs put the default button on the right side of dialogs. On all other platforms this is false by default.

    Window's guidelines advise to, "Position the most important button -- typically the default command -- as the first button in the set."


    leftControls

    protected JComponent[] leftControls

    dismissControls

    protected JComponent[] dismissControls

    lastSelectedComponent

    protected JComponent lastSelectedComponent

    autoClose

    protected boolean autoClose

    defaultButton

    protected JButton defaultButton

    closeDialogAndDisposeAction

    public static Action closeDialogAndDisposeAction
    This action takes the Window associated with the source of this event, hides it, and then calls dispose() on it.

    (This will not throw an exception if there is no parent window, but it does nothing in that case...)

    Constructor Detail

    DialogFooter

    public DialogFooter(JComponent[] leftControls,
                        JComponent[] dismissControls,
                        boolean autoClose,
                        JButton defaultButton)
    Create a new DialogFooter.

    Parameters:
    leftControls - the controls on the left side of this dialog, such as a help component, or a "Reset" button.
    dismissControls - the controls on the right side of this dialog that should dismiss this dialog. Also called "action" buttons.
    autoClose - whether the dismiss buttons should automatically close the containing window. If this is false, then it is assumed someone else is taking care of closing/disposing the containing dialog
    defaultButton - the optional button in dismissControls to make the default button in this dialog. (May be null.)
    Method Detail

    createCancelButton

    public static JButton createCancelButton(boolean escapeKeyIsTrigger)
    Creates a new "Cancel" button.

    Parameters:
    escapeKeyIsTrigger - if true then pressing the escape key will trigger this button. (Also on Macs command-period will act like the escape key.) This should be false if this button can lead to permanent data loss.

    makeEscapeKeyActivate

    public static void makeEscapeKeyActivate(AbstractButton button)
    This guarantees that when the escape key is pressed (if its parent window has the keyboard focus) this button is clicked.

    It is assumed that no two buttons will try to consume escape keys in the same window.

    Parameters:
    button - the button to trigger when the escape key is pressed.

    createOKButton

    public static JButton createOKButton()
    Creates a new "OK" button that is not triggered by the escape key.


    createOKButton

    public static JButton createOKButton(boolean escapeKeyIsTrigger)
    Creates a new "OK" button.

    Parameters:
    escapeKeyIsTrigger - if true then pressing the escape key will trigger this button. (Also on Macs command-period will act like the escape key.) This should be false if this button can lead to permanent data loss.

    createYesButton

    public static JButton createYesButton()
    Creates a new "Yes" button that is not triggered by the escape key.


    createYesButton

    public static JButton createYesButton(boolean escapeKeyIsTrigger)
    Creates a new "Yes" button.

    Parameters:
    escapeKeyIsTrigger - if true then pressing the escape key will trigger this button. (Also on Macs command-period will act like the escape key.) This should be false if this button can lead to permanent data loss.

    createNoButton

    public static JButton createNoButton()
    Creates a new "No" button that is not triggered by the escape key.


    createNoButton

    public static JButton createNoButton(boolean escapeKeyIsTrigger)
    Creates a new "No" button.

    Parameters:
    escapeKeyIsTrigger - if true then pressing the escape key will trigger this button. (Also on Macs command-period will act like the escape key.) This should be false if this button can lead to permanent data loss.

    createSaveButton

    public static JButton createSaveButton()
    Creates a new "Save" button that is not triggered by the escape key.


    createSaveButton

    public static JButton createSaveButton(boolean escapeKeyIsTrigger)
    Creates a new "Save" button.

    Parameters:
    escapeKeyIsTrigger - if true then pressing the escape key will trigger this button. (Also on Macs command-period will act like the escape key.) This should be false if this button can lead to permanent data loss.

    createDontSaveButton

    public static JButton createDontSaveButton()
    Creates a new "Don't Save" button that is not triggered by the escape key.


    createDontSaveButton

    public static JButton createDontSaveButton(boolean escapeKeyIsTrigger)
    Creates a new "Don't Save" button.

    Parameters:
    escapeKeyIsTrigger - if true then pressing the escape key will trigger this button. (Also on Macs command-period will act like the escape key.) This should be false if this button can lead to permanent data loss.

    createDialogFooter

    public static DialogFooter createDialogFooter(JComponent[] leftComponents,
                                                  int options,
                                                  int escapeKeyBehavior)
    Creates a DialogFooter and assigns a default button. The default button is the first button listed in the button type. For example, a YES_NO_CANCEL_OPTION dialog will make the YES_OPTION the default button.

    To use a different default button, use the other createDialogFooter() method.

    Parameters:
    leftComponents - the components to put on the left side of the footer.

    The Apple guidelines state that this area is reserved for "button[s] that affect the contents of the dialog itself, such as Reset [or Help]".

    options - one of the OPTIONS fields in this class, such as YES_NO_OPTION or CANCEL_OPTION.
    escapeKeyBehavior - one of the ESCAPE_KEY constants in this class.
    Returns:
    a DialogFooter

    createDialogFooter

    public static DialogFooter createDialogFooter(JComponent[] leftComponents,
                                                  int options,
                                                  int defaultButton,
                                                  int escapeKeyBehavior)
    Creates a DialogFooter.

    Parameters:
    leftComponents - the components to put on the left side of the footer.

    The Apple guidelines state that this area is reserved for "button[s] that affect the contents of the dialog itself, such as Reset [or Help]".

    options - one of the OPTIONS fields in this class, such as YES_NO_OPTION or CANCEL_OPTION.
    defaultButton - the OPTION field corresponding to the button that should be the default button, or -1 if there should be no default button.
    escapeKeyBehavior - one of the ESCAPE_KEY constants in this class.
    Returns:
    a DialogFooter

    normalizeButtons

    public static void normalizeButtons(JButton[] buttons)
    This takes a set of buttons and gives them all the width/height of the largest button among them.

    (More specifically, this sets the preferredSize of each button to the largest preferred size in the list of buttons.

    Parameters:
    buttons - an array of buttons.

    addActionListener

    public void addActionListener(ActionListener l)
    Adds an ActionListener.

    Parameters:
    l - this listener will be notified when a dismissControl is activated.

    removeActionListener

    public void removeActionListener(ActionListener l)
    Removes an ActionListener.


    getLastSelectedComponent

    public JComponent getLastSelectedComponent()
    Returns the component last used to dismiss the dialog.

    Note the components on the left side of this footer (such as a "Help" button or a "Reset Preferences" button) do NOT dismiss the dialog, and so this method has nothing to do with those components. This only related to the components on the right side of dialog.

    Returns:
    the component last used to dismiss the dialog.

    getButton

    public JButton getButton(int buttonType)
    Finds a certain type of button, if it is available.

    Parameters:
    buttonType - of the options in this class (such as YES_OPTION or CANCEL_OPTION)
    Returns:
    the button that maps to that option, or null if no such button was found.

    reset

    public void reset()
    This resets the value of lastSelectedComponent to null.

    If this footer is recycled in different dialogs, then you may need to nullify this value for getLastSelectedComponent() to remain relevant.


    getDismissControls

    public JComponent[] getDismissControls()
    Returns a copy of the dismissControls array used to construct this footer.


    getLeftControls

    public JComponent[] getLeftControls()
    Returns a copy of the leftControls array used to construct this footer.