Class ExtendedDialog

    • Constructor Detail

      • ExtendedDialog

        public ExtendedDialog​(Component parent,
                              String title,
                              String... buttonTexts)
        This method sets up the most basic options for the dialog. Add more advanced features with dedicated methods. Possible features:
        • setButtonIcons
        • setContent
        • toggleEnable
        • toggleDisable
        • setToggleCheckboxText
        • setRememberWindowGeometry
        When done, call showDialog to display it. You can receive the user's choice using getValue. Have a look at this function for possible return values.
        Parameters:
        parent - The parent element that will be used for position and maximum size
        title - The text that will be shown in the window titlebar
        buttonTexts - String Array of the text that will appear on the buttons. The first button is the default one.
      • ExtendedDialog

        public ExtendedDialog​(Component parent,
                              String title,
                              String[] buttonTexts,
                              boolean modal)
        Same as above but lets you define if the dialog should be modal.
        Parameters:
        parent - The parent element that will be used for position and maximum size
        title - The text that will be shown in the window titlebar
        buttonTexts - String Array of the text that will appear on the buttons. The first button is the default one.
        modal - Set it to true if you want the dialog to be modal
      • ExtendedDialog

        public ExtendedDialog​(Component parent,
                              String title,
                              String[] buttonTexts,
                              boolean modal,
                              boolean disposeOnClose)
        Same as above but lets you define if the dialog should be disposed on close.
        Parameters:
        parent - The parent element that will be used for position and maximum size
        title - The text that will be shown in the window titlebar
        buttonTexts - String Array of the text that will appear on the buttons. The first button is the default one.
        modal - Set it to true if you want the dialog to be modal
        disposeOnClose - whether to call Window.dispose() when closing the dialog
    • Method Detail

      • setContent

        public ExtendedDialog setContent​(Component content)
        Description copied from interface: IExtendedDialog
        Sets the content that will be displayed in the message dialog. Note that depending on your other settings more UI elements may appear. The content is played on top of the other elements though.
        Specified by:
        setContent in interface IExtendedDialog
        Parameters:
        content - Any element that can be displayed in the message dialog
        Returns:
        this
      • setContent

        public ExtendedDialog setContent​(Component content,
                                         boolean placeContentInScrollPane)
        Description copied from interface: IExtendedDialog
        Sets the content that will be displayed in the message dialog. Note that depending on your other settings more UI elements may appear. The content is played on top of the other elements though.
        Specified by:
        setContent in interface IExtendedDialog
        Parameters:
        content - Any element that can be displayed in the message dialog
        placeContentInScrollPane - if true, places the content in a JScrollPane
        Returns:
        this
      • setContent

        public ExtendedDialog setContent​(String message)
        Description copied from interface: IExtendedDialog
        Sets the message that will be displayed. The String will be automatically wrapped if it is too long. Note that depending on your other settings more UI elements may appear. The content is played on top of the other elements though.
        Specified by:
        setContent in interface IExtendedDialog
        Parameters:
        message - The text that should be shown to the user
        Returns:
        this
      • getValue

        public int getValue()
        Description copied from interface: IExtendedDialog
        Retrieve the user choice after the dialog has been closed.
        Specified by:
        getValue in interface IExtendedDialog
        Returns:
        • The selected button. The count starts with 1.
        • A return value of DialogClosedOtherwise means the dialog has been closed otherwise.
      • buttonAction

        protected void buttonAction​(int buttonIndex,
                                    ActionEvent evt)
        This gets performed whenever a button is clicked or activated
        Parameters:
        buttonIndex - the button index (first index is 0)
        evt - the button event
      • findMaxDialogSize

        protected Dimension findMaxDialogSize()
        Tries to find a good value of how large the dialog should be
        Returns:
        Dimension Size of the parent component if visible or 2/3 of screen size if not available or hidden
      • setupEscListener

        private void setupEscListener()
        Makes the dialog listen to ESC keypressed
      • setVisible

        public void setVisible​(boolean visible)
        Override setVisible to be able to save the window geometry if required
        Overrides:
        setVisible in class Dialog
      • setRememberWindowGeometry

        public ExtendedDialog setRememberWindowGeometry​(String pref,
                                                        WindowGeometry wg)
        Description copied from interface: IExtendedDialog
        Call this if you want the dialog to remember the geometry (size and position) set by the user. Set the pref to null or to an empty string to disable again. By default, it's disabled. Note: If you want to set the width of this dialog directly use the usual setSize, setPreferredSize, setMaxSize, setMinSize
        Specified by:
        setRememberWindowGeometry in interface IExtendedDialog
        Parameters:
        pref - The preference to save the dimension to
        wg - The default window geometry that should be used if no existing preference is found (only takes effect if pref is not null or empty
        Returns:
        this
      • toggleEnable

        public ExtendedDialog toggleEnable​(String togglePref)
        Description copied from interface: IExtendedDialog
        Calling this will offer the user a "Do not show again" checkbox for the dialog. Default is to not offer the choice; the dialog will be shown every time. Currently, this is not supported for non-modal dialogs.
        Specified by:
        toggleEnable in interface IExtendedDialog
        Parameters:
        togglePref - The preference to save the checkbox state to
        Returns:
        this
      • setCancelButton

        public ExtendedDialog setCancelButton​(Integer... cancelButtonIdx)
        Description copied from interface: IExtendedDialog
        Used in combination with toggle: If the user presses 'cancel' the toggle settings are ignored and not saved to the pref
        Specified by:
        setCancelButton in interface IExtendedDialog
        Parameters:
        cancelButtonIdx - index of the button that stands for cancel, accepts multiple values
        Returns:
        this
      • toggleSaveState

        protected void toggleSaveState()
        This function checks the state of the "Do not show again" checkbox and writes the corresponding pref.
      • string2label

        private static JMultilineLabel string2label​(String msg)
        Convenience function that converts a given string into a JMultilineLabel
        Parameters:
        msg - the message to display
        Returns:
        JMultilineLabel displaying msg
      • configureContextsensitiveHelp

        public ExtendedDialog configureContextsensitiveHelp​(String helpTopic,
                                                            boolean showHelpButton)
        Description copied from interface: IExtendedDialog
        Configures how this dialog support for context sensitive help.
        • if helpTopic is null, the dialog doesn't provide context sensitive help
        • if helpTopic != null, the dialog redirect user to the help page for this helpTopic when the user clicks F1 in the dialog
        • if showHelpButton is true, the dialog displays "Help" button (rightmost button in the button row)
        Specified by:
        configureContextsensitiveHelp in interface IExtendedDialog
        Parameters:
        helpTopic - the help topic
        showHelpButton - true, if the dialog displays a help button
        Returns:
        this