Class StandardDialog

All Implemented Interfaces:
ButtonNames, ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
MultiplePageDialog

public abstract class StandardDialog extends 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:
  • Field Details

    • _standardDialogPane

      protected StandardDialogPane _standardDialogPane
    • RESULT_CANCELLED

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

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

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

  • Method Details

    • 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 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(Action defaultCancelAction)
      Set default cancel action. Default cancel action will be triggered when ESC is pressed.
      Parameters:
      defaultCancelAction - the default cancel action
    • getDefaultAction

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

      public void setDefaultAction(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 Window
    • show

      @Deprecated public void show()
      Deprecated.
      As of JDK version 1.5, replaced by Component.setVisible(boolean).
      Overrides:
      show in class 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 Component getInitFocusedComponent()
      Gets the initial focused component when dialog is shown.
      Returns:
      the initial focused component
    • setInitFocusedComponent

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

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

      public 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.
    • getStandardDialogPane

      public StandardDialogPane getStandardDialogPane()
    • createBannerPanel

      public abstract 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 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:
    • createOKCancelButtonPanel

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

      protected StandardDialogPane createStandardDialogPane()