Class Dialogs.DialogOptions

  • Enclosing class:
    Dialogs

    public static class Dialogs.DialogOptions
    extends java.lang.Object
    A class that specifies all the options for displaying a dialog.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDialogClosedListener​(Dialogs.DialogClosedListener listener)
      Add a listener to be notified when a dialog constructed with these options is closed.
      java.lang.Object getCancelButton()
      Get the button which is treated as a cancel button.
      javax.swing.Icon getCustomIcon()
      Get the custom icon to use or null if none set
      java.lang.Object getDefaultButton()
      Get the button which is the dialogs default button.
      java.awt.Dimension getMaxDimensions()
      Get the maximum dimensions that the dialog will pack to.
      java.lang.String getTitle()
      Get the desired title for the dialog
      boolean isModal()
      Get whether the dialog should be modal.
      void setAdvancedOptionsInitiallyVisible​(boolean advancedOptionsInitiallyVisible)
      Set whether the advanced options panel or message is visible initially if a 'More Options Dialog' is shown with these options.
      void setAllowAsOwnerOfOtherDialogs​(boolean allowAsOwnerOfOtherDialogs)
      Normally a dialog will not be used as the owner of other dialogs (unless explicitly specified as the owner).
      void setCancelButton​(Dialogs.DialogAction cancelButton)
      Set the button which is treated as a cancel button.
      void setCancelButton​(java.lang.String cancelButton)
      Set the button which is treated as a cancel button.
      void setCloseAction​(Dialogs.DialogAction closeAction)
      Sets the action associated with clicking the windows's close button (the X in the top-right hand corner of the window in Windows).
      void setCustomIcon​(javax.swing.Icon customIcon)
      Set a custom icon to use instead of the standard JOptionPane ones.
      void setDefaultButton​(Dialogs.DialogAction defaultButton)
      Set the button which is the dialogs default button.
      void setDefaultButton​(java.lang.String defaultButton)
      Set the button which is the dialogs default button.
      void setMaxHeight​(int maxHeight)
      Set the maximum height that the dialog will pack itself to.
      void setMaxWidth​(int maxWidth)
      Set the maximum width that the dialog will pack itself to.
      void setModal​(boolean modal)
      Set whether the dialog should be modal.
      void setMoreOptionsButtonText​(java.lang.String moreOptionsText, java.lang.String lessOptionsText)
      If any of the showMoreOptionsDialog methods are used to show a dialog with these options then the specified text will be used on the More/Fewer Options button.
      void setTopLevelDialogWithTaskBarIcon​(boolean topLevelDialogWithTaskBarIcon)
      Sets this dialog as a top level window in the Geneious Prime application, with its own task bar icon on Windows.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DialogOptions

        public DialogOptions​(Dialogs.DialogOptions source)
        contstructs a new DialogOptions based on the given source.
        WARNING: this is a shallow copy, rather than a deep copy
        Parameters:
        source - the DialogOptions to copy
      • DialogOptions

        public DialogOptions​(Dialogs.DialogOptions source,
                             Dialogs.DialogAction okAction,
                             Dialogs.DialogAction cancelAction)
        contstructs a new DialogOptions based on the given source.
        WARNING: this is a shallow copy, rather than a deep copy
        Parameters:
        source - the DialogOptions to copy
        okAction - will be performed after the defaultAction is activated
        cancelAction - will be performed after the cancel action is activated
      • DialogOptions

        public DialogOptions​(java.lang.String[] buttons,
                             java.lang.String title)
        Parameters:
        buttons - Labels of the buttons in the dialog. The first is used as the default button (pressed if user pushes Enter) and is the right most button on MacOS or left most button on Windows. If there is more than one button then the last is treated as a Cancel button which is the left most button on MacOS or right most button on Windows. If the user closes the dialog or pushes Escape this is treated as if the Cancel button has been pressed. Never null
        title - Title of the dialog. For correct capitalisation, see TitleCap using option 'Capitalize words with five or more letters' (based on Use the Right Capitalization Style in Labels and Text)
      • DialogOptions

        public DialogOptions​(Dialogs.DialogAction[] buttons,
                             java.lang.String title)
        Parameters:
        buttons - Actions for the buttons in the dialog. The first is used as the default button (pressed if user pushes Enter) and is the right most button on MacOS or left most button on Windows. If there is more than one button then the last is treated as a Cancel button which is the left most button on MacOS or right most button on Windows. If the user closes the dialog or pushes Escape this is treated as if the Cancel button has been pressed. Never null
        title - Title of the dialog. For correct capitalisation, see TitleCap using option 'Capitalize words with five or more letters' (based on Use the Right Capitalization Style in Labels and Text)
      • DialogOptions

        public DialogOptions​(java.lang.String[] buttons,
                             java.lang.String title,
                             java.awt.Component owner)
        Parameters:
        buttons - Labels of the buttons in the dialog. The first is used as the default button (pressed if user pushes Enter) and is the right most button on MacOS or left most button on Windows. If there is more than one button then the last is treated as a Cancel button which is the left most button on MacOS or right most button on Windows. If the user closes the dialog or pushes Escape this is treated as if the Cancel button has been pressed. Never null
        title - Title of the dialog. For correct capitalisation, see TitleCap using option 'Capitalize words with five or more letters' (based on Use the Right Capitalization Style in Labels and Text)
        owner - Any component within the Window which will be the owner of this dialog. If null, the currently focused document frame (or JDialog with getClientProperty(ALLOW_AS_PARENT) != null) is used as the owner.
      • DialogOptions

        public DialogOptions​(Dialogs.DialogAction[] buttons,
                             java.lang.String title,
                             java.awt.Component owner)
        Parameters:
        buttons - Actions for the buttons in the dialog. The first is used as the default button (pressed if user pushes Enter) and is the right most button on MacOS or left most button on Windows. If there is more than one button then the last is treated as a Cancel button which is the left most button on MacOS or right most button on Windows. If the user closes the dialog or pushes Escape this is treated as if the Cancel button has been pressed. Never null
        title - Title of the dialog. For correct capitalisation, see TitleCap using option 'Capitalize words with five or more letters' (based on Use the Right Capitalization Style in Labels and Text)
        owner - Any component within the Window which will be the owner of this dialog. If null, the currently focused document frame (or JDialog with getClientProperty(ALLOW_AS_PARENT) != null) is used as the owner.
      • DialogOptions

        public DialogOptions​(java.lang.String[] buttons,
                             java.lang.String title,
                             java.awt.Component owner,
                             Dialogs.DialogIcon dialogIcon)
        Parameters:
        buttons - Labels of the buttons in the dialog. The first is used as the default button (pressed if user pushes Enter) and is the right most button on MacOS or left most button on Windows. If there is more than one button then the last is treated as a Cancel button which is the left most button on MacOS or right most button on Windows. If the user closes the dialog or pushes Escape this is treated as if the Cancel button has been pressed. Never null
        title - Title of the dialog. For correct capitalisation, see TitleCap using option 'Capitalize words with five or more letters' (based on Use the Right Capitalization Style in Labels and Text)
        owner - Any component within the Window which will be the owner of this dialog. If null, the currently focused document frame (or JDialog with getClientProperty(ALLOW_AS_PARENT) != null) is used as the owner.
        dialogIcon - The icon to display on the left of the dialog, eg. Dialogs.DialogIcon.WARNING, never null
      • DialogOptions

        public DialogOptions​(Dialogs.DialogAction[] buttons,
                             java.lang.String title,
                             java.awt.Component owner,
                             Dialogs.DialogIcon dialogIcon)
        Parameters:
        buttons - Actions for the buttons in the dialog. The first is used as the default button (pressed if user pushes Enter) and is the right most button on MacOS or left most button on Windows. If there is more than one button then the last is treated as a Cancel button which is the left most button on MacOS or right most button on Windows. If the user closes the dialog or pushes Escape this is treated as if the Cancel button has been pressed. Never null
        title - Title of the dialog. For correct capitalisation, see TitleCap using option 'Capitalize words with five or more letters' (based on Use the Right Capitalization Style in Labels and Text)
        owner - Any component within the Window which will be the owner of this dialog. If null, the currently focused document frame (or JDialog with getClientProperty(ALLOW_AS_PARENT) != null) is used as the owner.
        dialogIcon - The icon to display on the left of the dialog, eg. Dialogs.DialogIcon.WARNING, never null
    • Method Detail

      • setTopLevelDialogWithTaskBarIcon

        public void setTopLevelDialogWithTaskBarIcon​(boolean topLevelDialogWithTaskBarIcon)
        Sets this dialog as a top level window in the Geneious Prime application, with its own task bar icon on Windows.
        Parameters:
        topLevelDialogWithTaskBarIcon - true to make the dialog a top level window
        Since:
        API 4.202110 (Geneious 2021.1.0)
      • getMaxDimensions

        public java.awt.Dimension getMaxDimensions()
        Get the maximum dimensions that the dialog will pack to.
        Returns:
        the maximum dimensions
      • getTitle

        public java.lang.String getTitle()
        Get the desired title for the dialog
        Returns:
        the desired title for the dialog
      • setMaxWidth

        public void setMaxWidth​(int maxWidth)
        Set the maximum width that the dialog will pack itself to. The user can manually resize it larger than this.
        Parameters:
        maxWidth - maximum width for the dialog
      • setMaxHeight

        public void setMaxHeight​(int maxHeight)
        Set the maximum height that the dialog will pack itself to. The user can manually resize it larger than this.
        Parameters:
        maxHeight - maximum height for the dialog
      • getCancelButton

        public java.lang.Object getCancelButton()
        Get the button which is treated as a cancel button. This will be either a String or an Dialogs.DialogAction depending on what was used to specify the buttons for these options. If this dialog has only a single button, this method will return that button, even if it is an OK button!
        Returns:
        the button which is treated as a cancel button.
      • setCloseAction

        public void setCloseAction​(Dialogs.DialogAction closeAction)
        Sets the action associated with clicking the windows's close button (the X in the top-right hand corner of the window in Windows). This does not need to be one of the buttons passed to the constructor.
        Parameters:
        closeAction - the action (usually Dialogs.CANCEL) or null for the close action to be the same as the cancel button.
      • setCancelButton

        public void setCancelButton​(Dialogs.DialogAction cancelButton)
        Set the button which is treated as a cancel button. This must be one of the buttons passed to the constructor.
        Parameters:
        cancelButton - the button which is treated as a cancel button.
        See Also:
        setCancelButton(String)
      • getDefaultButton

        public java.lang.Object getDefaultButton()
        Get the button which is the dialogs default button. This will be either a String or an Dialogs.DialogAction depending on what was used to specify the buttons for these options.
        Returns:
        the button which is the dialogs default button.
      • setDefaultButton

        public void setDefaultButton​(Dialogs.DialogAction defaultButton)
        Set the button which is the dialogs default button. This must be one of the buttons passed to the constructor
        Parameters:
        defaultButton - the button which is the dialogs default button.
        See Also:
        setDefaultButton(String)
      • isModal

        public boolean isModal()
        Get whether the dialog should be modal.
        Returns:
        true if the dialog should be modal
      • setModal

        public void setModal​(boolean modal)
        Set whether the dialog should be modal.

        WARNING setting this to false will cause any of the Dialogs show methods to return a null result as soon as the dialog is displayed. The dialog will not wait for input from the user. You should use DialogActions to receive events from the buttons in this case.

        Parameters:
        modal - true if the dialog should be modal
      • getCustomIcon

        public javax.swing.Icon getCustomIcon()
        Get the custom icon to use or null if none set
        Returns:
        the custom icon to use or null if none set
      • setCustomIcon

        public void setCustomIcon​(javax.swing.Icon customIcon)
        Set a custom icon to use instead of the standard JOptionPane ones. If a custom icon is set then the iconType setting will be ignored.
        Parameters:
        customIcon - the custom icon to use