Class ApprovalDialog

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class ApprovalDialog extends DialogWithButtons
Ancestor for dialogs that offer approval/disapproval buttons, e.g., OK and Cancel (default). The option selected by the user can be retrieved via getOption().
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
  • Field Details

    • APPROVE_OPTION

      public static final int APPROVE_OPTION
      the approve option.
      See Also:
    • DISCARD_OPTION

      public static final int DISCARD_OPTION
      the discard option.
      See Also:
    • CANCEL_OPTION

      public static final int CANCEL_OPTION
      the cancel option.
      See Also:
    • m_ButtonApprove

      protected JButton m_ButtonApprove
      the Approve button.
    • m_ButtonDiscard

      protected JButton m_ButtonDiscard
      the Discard button.
    • m_ButtonCancel

      protected JButton m_ButtonCancel
      the Cancel button.
    • m_Option

      protected int m_Option
      the option selected by the user (CANCEL_OPTION, APPROVE_OPTION).
  • Constructor Details

    • ApprovalDialog

      public ApprovalDialog(Dialog owner)
      Creates a modeless dialog without a title with the specified Dialog as its owner.
      Parameters:
      owner - the owning dialog
    • ApprovalDialog

      public ApprovalDialog(Dialog owner, Dialog.ModalityType modality)
      Creates a dialog with the specified owner Dialog and modality.
      Parameters:
      owner - the owning dialog
      modality - the type of modality
    • ApprovalDialog

      public ApprovalDialog(Dialog owner, String title)
      Creates a modeless dialog with the specified title and with the specified owner dialog.
      Parameters:
      owner - the owning dialog
      title - the title of the dialog
    • ApprovalDialog

      public ApprovalDialog(Dialog owner, String title, Dialog.ModalityType modality)
      Creates a dialog with the specified title, modality and the specified owner Dialog.
      Parameters:
      owner - the owning dialog
      title - the title of the dialog
      modality - the type of modality
    • ApprovalDialog

      public ApprovalDialog(Frame owner)
      Creates a modeless dialog without a title with the specified Frame as its owner.
      Parameters:
      owner - the owning frame
    • ApprovalDialog

      public ApprovalDialog(Frame owner, boolean modal)
      Creates a dialog with the specified owner Frame, modality and an empty title.
      Parameters:
      owner - the owning frame
      modal - whether the dialog is modal or not
    • ApprovalDialog

      public ApprovalDialog(Frame owner, String title)
      Creates a modeless dialog with the specified title and with the specified owner frame.
      Parameters:
      owner - the owning frame
      title - the title of the dialog
    • ApprovalDialog

      public ApprovalDialog(Frame owner, String title, boolean modal)
      Creates a dialog with the specified owner Frame, modality and title.
      Parameters:
      owner - the owning frame
      title - the title of the dialog
      modal - whether the dialog is modal or not
  • Method Details

    • initialize

      protected void initialize()
      Initializes the members.
      Overrides:
      initialize in class BaseDialog
    • initGUI

      protected void initGUI()
      Initializes the widgets.
      Overrides:
      initGUI in class DialogWithButtons
    • getOption

      public int getOption()
      Returns whether the user approved or canceled the dialog.
      Returns:
      the result
      See Also:
    • beforeShow

      protected void beforeShow()
      Hook method just before the dialog is made visible.
      Overrides:
      beforeShow in class BaseDialog
    • checkInput

      protected String checkInput()
      Hook method for the "approve" button. Button triggers only if this method returns null.

      Default implementation returns null.
      Returns:
      null if the input is valid, otherwise error message
    • getApproveButton

      public JButton getApproveButton()
      Returns the approve button.
      Returns:
      the button
    • setApproveVisible

      public void setApproveVisible(boolean value)
      Sets the visbility of the approve button.
      Parameters:
      value - true if to display button
    • isApproveVisible

      public boolean isApproveVisible()
      Returns the visibility of the approve button.
      Returns:
      true if visible
    • setApproveCaption

      public void setApproveCaption(String value)
      Sets the caption/text of the approve button.
      Parameters:
      value - the new text
    • getApproveCaption

      public String getApproveCaption()
      Returns the caption/text of the approve button.
      Returns:
      the current text
    • setApproveMnemonic

      public void setApproveMnemonic(int value)
      Sets the mnemonic of the approve button.
      Parameters:
      value - the new mnemonic, e.g., KeyEvent.VK_O
    • getApproveMnemonic

      public int getApproveMnemonic()
      Returns the mnemonic of the approve button.
      Returns:
      the current mnemonic, e.g., KeyEvent.VK_O
    • getDiscardButton

      public JButton getDiscardButton()
      Returns the discard button.
      Returns:
      the button
    • setDiscardVisible

      public void setDiscardVisible(boolean value)
      Sets the visbility of the discard button.
      Parameters:
      value - true if to display button
    • isDiscardVisible

      public boolean isDiscardVisible()
      Returns the visibility of the discard button.
      Returns:
      true if visible
    • setDiscardCaption

      public void setDiscardCaption(String value)
      Sets the caption/text of the discard button.
      Parameters:
      value - the new text
    • getDiscardCaption

      public String getDiscardCaption()
      Returns the caption/text of the discard button.
      Returns:
      the current text
    • setDiscardMnemonic

      public void setDiscardMnemonic(int value)
      Sets the mnemonic of the discard button.
      Parameters:
      value - the new mnemonic, e.g., KeyEvent.VK_D
    • getDiscardMnemonic

      public int getDiscardMnemonic()
      Returns the mnemonic of the discard button.
      Returns:
      the current mnemonic, e.g., KeyEvent.VK_D
    • getCancelButton

      public JButton getCancelButton()
      Returns the cancel button.
      Returns:
      the button
    • setCancelVisible

      public void setCancelVisible(boolean value)
      Sets the visbility of the cancel button.
      Parameters:
      value - true if to display button
    • isCancelVisible

      public boolean isCancelVisible()
      Returns the visibility of the cancel button.
      Returns:
      true if visible
    • setCancelCaption

      public void setCancelCaption(String value)
      Sets the caption/text of the Cancel button.
      Parameters:
      value - the new text
    • getCancelCaption

      public String getCancelCaption()
      Returns the caption/text of the Cancel button.
      Returns:
      the current text
    • setCancelMnemonic

      public void setCancelMnemonic(int value)
      Sets the mnemonic of the Cancel button.
      Parameters:
      value - the new mnemonic, e.g., KeyEvent.VK_C
    • getCancelMnemonic

      public int getCancelMnemonic()
      Returns the mnemonic of the Cancel button.
      Returns:
      the current mnemonic, e.g., KeyEvent.VK_C
    • getDialog

      public static ApprovalDialog getDialog(Dialog owner)
      Returns a basic (modal) approval dialog (ok/cancel).
      Parameters:
      owner - the owner of the dialog
    • getDialog

      public static ApprovalDialog getDialog(Dialog owner, Dialog.ModalityType modal)
      Returns a basic approval dialog (ok/cancel).
      Parameters:
      owner - the owner of the dialog
      modal - the modality of the dialog
    • getDialog

      public static ApprovalDialog getDialog(Frame owner)
      Returns a basic (modal) approval dialog (ok/cancel).
      Parameters:
      owner - the owner of the dialog
    • getDialog

      public static ApprovalDialog getDialog(Frame owner, boolean modal)
      Returns a basic (modal) approval dialog (ok/cancel).
      Parameters:
      owner - the owner of the dialog
      modal - whether to create a modal frame
    • getConfirmationDialog

      public static ApprovalDialog getConfirmationDialog(Dialog owner)
      Returns a basic (modal) confirmation dialog (yes/no/cancel).
      Parameters:
      owner - the owner of the dialog
    • getConfirmationDialog

      public static ApprovalDialog getConfirmationDialog(Dialog owner, Dialog.ModalityType modal)
      Returns a basic confirmation dialog (yes/no/cancel).
      Parameters:
      owner - the owner of the dialog
      modal - the modality of the dialog
    • getConfirmationDialog

      public static ApprovalDialog getConfirmationDialog(Frame owner)
      Returns a basic (modal) confirmation dialog (yes/no/cancel).
      Parameters:
      owner - the owner of the dialog
    • getConfirmationDialog

      public static ApprovalDialog getConfirmationDialog(Frame owner, boolean modal)
      Returns a basic confirmation dialog (yes/no/cancel).
      Parameters:
      owner - the owner of the dialog
      modal - whether to create a modal dialog
    • getInformationDialog

      public static ApprovalDialog getInformationDialog(Dialog owner)
      Returns a basic (modal) info dialog (ok).
      Parameters:
      owner - the owner of the dialog
    • getInformationDialog

      public static ApprovalDialog getInformationDialog(Dialog owner, Dialog.ModalityType modal)
      Returns a basic info dialog (ok).
      Parameters:
      owner - the owner of the dialog
      modal - the modality of the dialog
    • getInformationDialog

      public static ApprovalDialog getInformationDialog(Frame owner)
      Returns a basic (modal) info dialog (ok).
      Parameters:
      owner - the owner of the dialog
    • getInformationDialog

      public static ApprovalDialog getInformationDialog(Frame owner, boolean modal)
      Returns a basic info dialog (ok).
      Parameters:
      owner - the owner of the dialog
      modal - whether to create a modal dialog