Class StandardDialogPane

All Implemented Interfaces:
ButtonNames, ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
MultiplePageDialogPane, StandardDialog.DefaultStandardDialogPane

public abstract class StandardDialogPane extends JPanel implements ButtonNames
StandardDialogPane is the content pane of StandardDialog. It can also be used when you want the template of StandardDialog but you don't want to use JDialog.
  • Introduce laziness. The content will not be filled until pack() or show() be called.
  • Default action and cancel action. User can set default action and cancel action of this dialog. By default, ENTER key will trigger the default action and 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 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()

StandardDialogPane has lazy loading feature. So when you are done setup the page list, you need to call initComponents() to initialize everything. This method will be called automatically if the dialog pane is added to StandardDialog. Basically, if you want to add StandardDialogPane without StandardDialog, the following code are required for the pane to be ready to add to its parent container.

 pane = new StandardDialogPane() {
     public JComponent createBannerPanel() {
         return null;
     }
 

public JComponent createContentPanel() { return null; }

public ButtonPanel createButtonPanel() { return null; } }; pane.initComponents();

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • 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 ENTEY key is pressed.
      Returns:
      the default action.
    • setDefaultAction

      public void setDefaultAction(Action defaultAction)
      Sets the default action. Default action will be trigger when ENTEY key is pressed.
      Parameters:
      defaultAction - the default action.
    • initComponents

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

    • layoutComponents

      protected void layoutComponents(Component bannerPanel, Component contentPanel, ButtonPanel buttonPanel)
      Setups the layout for the three panels - banner panel, content panel and button panel. By default, we will use BorderLayout, put the content panel in the middle, banner panel on the top and button panel either right or bottom depending on its alignment.

      Subclass can override it to do your own layout. The three panels are the three parameters.

      Parameters:
      bannerPanel - the banner panel
      contentPanel - the content panel
      buttonPanel - the button panel
    • 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.
    • 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: