Class StandardDialog

  • All Implemented Interfaces:
    ButtonNames, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants
    Direct Known Subclasses:
    MultiplePageDialog

    public abstract class StandardDialog
    extends javax.swing.JDialog
    implements ButtonNames
    StandardDialog is a dialog template. However several things are added to it to make it easier to use.
    • Laziness. The content will not be filled until pack() or show() are called.
    • Default action and cancel action. User can set the default action and cancel action of this dialog. By default, the ENTER key will trigger the default action and the ESC key will trigger the cancel action and set the dialog result to RESULT_CANCELLED.
    • Divide the whole ContentPane of the dialog into three parts - content panel, button panel and banner panel. By default, they are added to the CENTER, SOUTH and NORTH of a BorderLayout respectively. There isn't anything special about this. However if all your dialogs use this pattern, it will automatically make the user interface more consistent.

    This class is abstract. Subclasses need to implement createBannerPanel(), createButtonPanel() and createContentPanel()

    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  StandardDialog.DefaultStandardDialogPane  
      • 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, java.awt.Window.Type
      • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      StandardDialog()  
      StandardDialog​(java.awt.Dialog owner)  
      StandardDialog​(java.awt.Dialog owner, boolean modal)  
      StandardDialog​(java.awt.Dialog owner, java.lang.String title)  
      StandardDialog​(java.awt.Dialog owner, java.lang.String title, boolean modal)  
      StandardDialog​(java.awt.Dialog owner, java.lang.String title, boolean modal, java.awt.GraphicsConfiguration gc)  
      StandardDialog​(java.awt.Frame owner)  
      StandardDialog​(java.awt.Frame owner, boolean modal)  
      StandardDialog​(java.awt.Frame owner, java.lang.String title)  
      StandardDialog​(java.awt.Frame owner, java.lang.String title, boolean modal)  
      StandardDialog​(java.awt.Frame owner, java.lang.String title, boolean modal, java.awt.GraphicsConfiguration gc)  
      StandardDialog​(java.awt.Window owner)  
      StandardDialog​(java.awt.Window owner, java.awt.Dialog.ModalityType modalityType)  
      StandardDialog​(java.awt.Window owner, java.lang.String title)  
      StandardDialog​(java.awt.Window owner, java.lang.String title, java.awt.Dialog.ModalityType modalityType)  
      StandardDialog​(java.awt.Window owner, java.lang.String title, java.awt.Dialog.ModalityType modalityType, java.awt.GraphicsConfiguration gc)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      abstract javax.swing.JComponent createBannerPanel()
      Subclasses should implement this method to create the banner panel.
      abstract ButtonPanel createButtonPanel()
      Subclasses should implement this method to create the button panel.
      abstract javax.swing.JComponent createContentPanel()
      Subclasses should implement this method to create the content panel.
      ButtonPanel createOKCancelButtonPanel()
      Creates a standard OK/Cancel button panel.
      protected StandardDialogPane createStandardDialogPane()  
      javax.swing.JComponent getBannerPanel()
      Gets the banner panel created by createBannerPanel.
      ButtonPanel getButtonPanel()
      Gets the banner panel created by createButtonPanel.
      javax.swing.JComponent getContentPanel()
      Gets the banner panel created by createContentPanel.
      javax.swing.Action getDefaultAction()
      Gets the default action.
      javax.swing.Action getDefaultCancelAction()
      Get default cancel action.
      int getDialogResult()
      Gets the result.
      java.awt.Component getInitFocusedComponent()
      Gets the initial focused component when dialog is shown.
      StandardDialogPane getStandardDialogPane()  
      protected void initComponents()
      Call three createXxxPanel methods and layout them using BorderLayout.
      void initialize()
      Force the initComponent() method implemented in the child class to be called.
      void pack()  
      void setDefaultAction​(javax.swing.Action defaultAction)
      Sets the default action.
      void setDefaultCancelAction​(javax.swing.Action defaultCancelAction)
      Set default cancel action.
      void setDialogResult​(int dialogResult)
      Sets the dialog result.
      void setInitFocusedComponent​(java.awt.Component initFocusedComponent)
      Sets the initial focused component when dialog is shown.
      void show()
      Deprecated.
      As of JDK version 1.5, replaced by Component.setVisible(boolean).
      • Methods inherited from class javax.swing.JDialog

        addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, 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, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, toBack
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, 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, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, 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, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, 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

      • RESULT_CANCELLED

        public static final int RESULT_CANCELLED
        Dialog result.
        See Also:
        Constant Field Values
      • RESULT_AFFIRMED

        public static final int RESULT_AFFIRMED
        Dialog result.
        See Also:
        Constant Field Values
      • _propertyChangeListener

        public com.jidesoft.dialog.StandardDialog.StandardDialogPropertyChangeListener _propertyChangeListener
    • Constructor Detail

      • StandardDialog

        public StandardDialog()
      • StandardDialog

        public StandardDialog​(java.awt.Frame owner)
      • StandardDialog

        public StandardDialog​(java.awt.Frame owner,
                              boolean modal)
      • StandardDialog

        public StandardDialog​(java.awt.Frame owner,
                              java.lang.String title)
      • StandardDialog

        public StandardDialog​(java.awt.Frame owner,
                              java.lang.String title,
                              boolean modal)
      • StandardDialog

        public StandardDialog​(java.awt.Frame owner,
                              java.lang.String title,
                              boolean modal,
                              java.awt.GraphicsConfiguration gc)
      • StandardDialog

        public StandardDialog​(java.awt.Dialog owner)
      • StandardDialog

        public StandardDialog​(java.awt.Dialog owner,
                              boolean modal)
      • StandardDialog

        public StandardDialog​(java.awt.Dialog owner,
                              java.lang.String title)
      • StandardDialog

        public StandardDialog​(java.awt.Dialog owner,
                              java.lang.String title,
                              boolean modal)
      • StandardDialog

        public StandardDialog​(java.awt.Dialog owner,
                              java.lang.String title,
                              boolean modal,
                              java.awt.GraphicsConfiguration gc)
      • StandardDialog

        public StandardDialog​(java.awt.Window owner)
      • StandardDialog

        public StandardDialog​(java.awt.Window owner,
                              java.lang.String title)
      • StandardDialog

        public StandardDialog​(java.awt.Window owner,
                              java.awt.Dialog.ModalityType modalityType)
      • StandardDialog

        public StandardDialog​(java.awt.Window owner,
                              java.lang.String title,
                              java.awt.Dialog.ModalityType modalityType)
      • StandardDialog

        public StandardDialog​(java.awt.Window owner,
                              java.lang.String title,
                              java.awt.Dialog.ModalityType modalityType,
                              java.awt.GraphicsConfiguration gc)
    • Method Detail

      • getDialogResult

        public int getDialogResult()
        Gets the result.
        Returns:
        the result.
      • setDialogResult

        public void setDialogResult​(int dialogResult)
        Sets the dialog result.
        Parameters:
        dialogResult - the new dialog result.
      • getDefaultCancelAction

        public javax.swing.Action getDefaultCancelAction()
        Get default cancel action. Default cancel action will be triggered when ESC is pressed.
        Returns:
        the default cancel action
      • setDefaultCancelAction

        public void setDefaultCancelAction​(javax.swing.Action defaultCancelAction)
        Set default cancel action. Default cancel action will be triggered when ESC is pressed.
        Parameters:
        defaultCancelAction - the default cancel action
      • getDefaultAction

        public javax.swing.Action getDefaultAction()
        Gets the default action. Default action will be trigger when ENTER key is pressed.
        Returns:
        the default action.
      • setDefaultAction

        public void setDefaultAction​(javax.swing.Action defaultAction)
        Sets the default action. Default action will be trigger when ENTER key is pressed.
        Parameters:
        defaultAction - the default action.
      • pack

        public void pack()
        Overrides:
        pack in class java.awt.Window
      • show

        @Deprecated
        public void show()
        Deprecated.
        As of JDK version 1.5, replaced by Component.setVisible(boolean).
        Overrides:
        show in class java.awt.Dialog
      • initialize

        public final void initialize()
        Force the initComponent() method implemented in the child class to be called. If this method is called more than once on a given object, all calls but the first do nothing.
      • initComponents

        protected void initComponents()
        Call three createXxxPanel methods and layout them using BorderLayout. By default, banner panel, content panel and button panel are added to NORTH, CENTER and SOUTH of BorderLayout respectively.

        You can override this method if you want to layout them in another way.

      • getInitFocusedComponent

        public java.awt.Component getInitFocusedComponent()
        Gets the initial focused component when dialog is shown.
        Returns:
        the initial focused component
      • setInitFocusedComponent

        public void setInitFocusedComponent​(java.awt.Component initFocusedComponent)
        Sets the initial focused component when dialog is shown.
        Parameters:
        initFocusedComponent - the initial focused component.
      • getBannerPanel

        public javax.swing.JComponent getBannerPanel()
        Gets the banner panel created by createBannerPanel.
        Returns:
        the banner panel.
      • getContentPanel

        public javax.swing.JComponent getContentPanel()
        Gets the banner panel created by createContentPanel.
        Returns:
        the content panel.
      • getButtonPanel

        public ButtonPanel getButtonPanel()
        Gets the banner panel created by createButtonPanel.
        Returns:
        the button panel.
      • createBannerPanel

        public abstract javax.swing.JComponent createBannerPanel()
        Subclasses should implement this method to create the banner panel. By default banner panel will appear on top of the dialog unless you override initComponent() method. Banner panel is really used to balance the layout of dialog to make the dialog looking good. However it can be used to show some help text. It is highly recommended to use our BannerPanel

        If subclass doesn't want to have a banner panel, just return null.

        Returns:
        the banner panel.
      • createContentPanel

        public abstract javax.swing.JComponent createContentPanel()
        Subclasses should implement this method to create the content panel. This is the main panel of the dialog which will be added to the center of the dialog. Subclass should never return null.
        Returns:
        the content panel.
      • createButtonPanel

        public abstract ButtonPanel createButtonPanel()
        Subclasses should implement this method to create the button panel. 90% of dialogs have buttons. It is highly recommended to use our ButtonPanel.
        Returns:
        the button panel.
        See Also:
        ButtonPanel
      • createOKCancelButtonPanel

        public ButtonPanel createOKCancelButtonPanel()
        Creates a standard OK/Cancel button panel.
        Returns:
        a button panel that has OK/Cancel button.