Class Dialog

  • All Implemented Interfaces:
    Cullable, Layout

    public class Dialog
    extends Window
    Displays a dialog, which is a window with a title, a content table, and a button table. Methods are provided to add a label to the content table and buttons to the button table, but any widgets can be added. When a button is clicked, result(Object) is called and the dialog is removed from the stage.
    • Constructor Detail

      • Dialog

        public Dialog​(java.lang.String title,
                      Skin skin)
      • Dialog

        public Dialog​(java.lang.String title,
                      Skin skin,
                      java.lang.String windowStyleName)
    • Method Detail

      • setStage

        protected void setStage​(Stage stage)
        Description copied from class: Actor
        Called by the framework when this actor or any ascendant is added to a group that is in the stage.
        Overrides:
        setStage in class Group
        Parameters:
        stage - May be null if the actor or any ascendant is no longer in a stage.
      • getContentTable

        public Table getContentTable()
      • getButtonTable

        public Table getButtonTable()
      • text

        public Dialog text​(@Null
                           java.lang.String text)
        Adds a label to the content table. The dialog must have been constructed with a skin to use this method.
      • text

        public Dialog text​(Label label)
        Adds the given Label to the content table
      • button

        public Dialog button​(@Null
                             java.lang.String text)
        Adds a text button to the button table. Null will be passed to result(Object) if this button is clicked. The dialog must have been constructed with a skin to use this method.
      • button

        public Dialog button​(@Null
                             java.lang.String text,
                             @Null
                             java.lang.Object object)
        Adds a text button to the button table. The dialog must have been constructed with a skin to use this method.
        Parameters:
        object - The object that will be passed to result(Object) if this button is clicked. May be null.
      • button

        public Dialog button​(@Null
                             java.lang.String text,
                             @Null
                             java.lang.Object object,
                             TextButton.TextButtonStyle buttonStyle)
        Adds a text button to the button table.
        Parameters:
        object - The object that will be passed to result(Object) if this button is clicked. May be null.
      • button

        public Dialog button​(Button button)
        Adds the given button to the button table.
      • button

        public Dialog button​(Button button,
                             @Null
                             java.lang.Object object)
        Adds the given button to the button table.
        Parameters:
        object - The object that will be passed to result(Object) if this button is clicked. May be null.
      • show

        public Dialog show​(Stage stage,
                           @Null
                           Action action)
        Packs the dialog (but doesn't set the position), adds it to the stage, sets it as the keyboard and scroll focus, clears any actions on the dialog, and adds the specified action to it. The previous keyboard and scroll focus are remembered so they can be restored when the dialog is hidden.
        Parameters:
        action - May be null.
      • hide

        public void hide​(@Null
                         Action action)
        Removes the dialog from the stage, restoring the previous keyboard and scroll focus, and adds the specified action to the dialog.
        Parameters:
        action - If null, the dialog is removed immediately. Otherwise, the dialog is removed when the action completes. The dialog will not respond to touch down events during the action.
      • hide

        public void hide()
        Hides the dialog. Called automatically when a button is clicked. The default implementation fades out the dialog over 400 milliseconds.
      • setObject

        public void setObject​(Actor actor,
                              @Null
                              java.lang.Object object)
      • result

        protected void result​(@Null
                              java.lang.Object object)
        Called when a button is clicked. The dialog will be hidden after this method returns unless cancel() is called.
        Parameters:
        object - The object specified when the button was added.
      • cancel

        public void cancel()