Class AbstractSimpleDialog

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

public abstract class AbstractSimpleDialog extends JDialog
An abstract base class for simple dialogs with a single control panel (supplied by the sub-class) together with OK and Cancel buttons. The sub-class must implement the createControlPanel() and onOK() methods.
Since:
2.7
Author:
Michael Bedward
See Also:
  • Constructor Details

    • AbstractSimpleDialog

      public AbstractSimpleDialog(String title)
      Creates a new modal, non-resizable dialog with a null parent.
      Parameters:
      title - dialog title
    • AbstractSimpleDialog

      public AbstractSimpleDialog(JFrame parent, String title)
      Creates a new modal, non-resizable dialog.
      Parameters:
      parent - parent frame
      title - dialog title
    • AbstractSimpleDialog

      public AbstractSimpleDialog(JDialog parent, String title)
      Creates a new modal, non-resizable dialog.
      Parameters:
      parent - parent dialog
      title - dialog title
    • AbstractSimpleDialog

      public AbstractSimpleDialog(JFrame parent, String title, boolean modal, boolean resizable)
      Creates a new modal, non-resizable dialog.
      Parameters:
      parent - parent frame
      title - dialog title
      modal - whether to make the dialog application modal
      resizable - whether to make the dialog resizable
    • AbstractSimpleDialog

      public AbstractSimpleDialog(JDialog parent, String title, boolean modal, boolean resizable)
      Creates a new modal, non-resizable dialog.
      Parameters:
      parent - parent dialog
      title - dialog title
      modal - whether to make the dialog application modal
      resizable - whether to make the dialog resizable
  • Method Details

    • setVisible

      public void setVisible(boolean b)
      Overrides:
      setVisible in class Dialog
    • initComponents

      protected void initComponents()
      Creates the main control panel and components. This must be called by the sub-class. We do this to give sub-classes the chance to initialize fields which can be used within createControlPanel() (called as part of this method).
    • createControlPanel

      public abstract JPanel createControlPanel()
      Implemented by the sub-class to provide a panel with controls.
      Returns:
      panel with controls
    • onOK

      public abstract void onOK()
      Implemented by the sub-class to respond to the OK button.
    • onCancel

      public void onCancel()
      Called when the cancel button is pressed. The base implementation simply closes (disposes) the dialog.
    • closeDialog

      public void closeDialog()
      Close the dialog using a call to Window.dispose().
    • createButtonPanel

      protected JPanel createButtonPanel()
      Creates the OK and Cancel buttons on a panel.
      Returns:
      the button panel