Class AbstractButtonDialog

All Implemented Interfaces:
WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
AbstractChoiceDialog, AbstractIconChooserDialog, AbstractNagDialog, AbstractValidationButtonDialog, AdvancedSearchDialog, AdvancedSearchMapDialog, BotConfigDialog, BotConfigTargetHexDialog, BotConfigTargetUnitDialog, CommonSettingsDialog, CustomMekDialog, EditBotsDialog, FloodDialog, GameOptionsDialog, LevelChangeDialog, LOSDialog, MultiIntSelectorDialog, PlayerSettingsDialog, ScenarioChooserDialog, SkillGenerationDialog

public abstract class AbstractButtonDialog extends AbstractDialog
This is the Base Dialog for a dialog with buttons in MegaMek. It extends Base Dialog, and adds a button panel with base Ok and Cancel buttons. It also includes an enum tracker for the result of the dialog. Inheriting classes must call initialize() in their constructors and override createCenterPane() The resources associated with this dialog need to contain at least the following keys: - "Ok.text" - text for the ok button - "Ok.toolTipText" - toolTipText for the ok button - "Cancel.text" - text for the cancel button - "Cancel.toolTipText" - toolTipText for the cancel button This is directly tied to MekHQ's AbstractMHQButtonDialog, and any changes here MUST be verified there.
See Also:
  • Constructor Details

    • AbstractButtonDialog

      protected AbstractButtonDialog(JFrame frame, String name, String title)
      This creates a modal AbstractButtonDialog using the default resource bundle. This is the normal constructor to use for an AbstractButtonDialog.
      Parameters:
      frame - Frame to connect to.
      name - Name for the button.
      title - Title of the dialog.
    • AbstractButtonDialog

      protected AbstractButtonDialog(JFrame frame, boolean modal, String name, String title)
      This creates an AbstractButtonDialog using the default resource bundle. It allows one to create non-modal button dialogs.
      Parameters:
      frame - Window frame to connect to.
      modal - Whether to open modally
      name - Name on the button.
      title - Title of window
    • AbstractButtonDialog

      protected AbstractButtonDialog(JFrame frame, boolean modal, ResourceBundle resources, String name, String title)
      This creates an AbstractButtonDialog using the specified resource bundle. This is not recommended by default.
    • AbstractButtonDialog

      protected AbstractButtonDialog(JDialog dialog, JFrame frame, boolean modal, ResourceBundle resources, String name, String title)
      This constructor is provided for uses cases where this dialog needs another dialog as a parent.
  • Method Details

    • getResult

      public DialogResult getResult()
    • setResult

      public void setResult(DialogResult result)
    • initialize

      protected void initialize()
      Initializes the dialog's UI and preferences. Needs to be called by child classes for initial setup. Anything that overrides this method MUST end by calling AbstractDialog.finalizeInitialization()
      Overrides:
      initialize in class AbstractDialog
    • createButtonPanel

      protected JPanel createButtonPanel()
      Returns:
      the created Button Panel
    • okButtonActionPerformed

      protected void okButtonActionPerformed(ActionEvent evt)
      This is the default Action Event Listener for the Ok Button's action. This triggers the Ok Action, sets the result to confirmed, and then sets the dialog so that it is no longer visible.
      Parameters:
      evt - the event triggering this
    • okAction

      protected void okAction()
      Action performed when the Ok button is clicked.
    • showDialog

      public DialogResult showDialog()
      Sets the dialog to be visible, before returning the result
      Returns:
      the result of showing the dialog