org.gnome.gtk

## Class MessageDialog

- Object
- - org.freedesktop.bindings.Pointer
  - - org.freedesktop.bindings.Proxy
    - - org.gnome.glib.Object
      - - org.gnome.gtk.Widget
        - - org.gnome.gtk.Container
          - - org.gnome.gtk.Bin
            - - org.gnome.gtk.Window
              - - org.gnome.gtk.Dialog
                - - org.gnome.gtk.MessageDialog

- Direct Known Subclasses:
    ErrorMessageDialog, InfoMessageDialog, QuestionMessageDialog, WarningMessageDialog

      public class MessageDialog
      extends Dialog

  A convenient Dialog to show a message to the user.

  MessageDialogs are used to show some information message to the user, warn him about application errors or problems, and let him choose what action to take.

  A MessageDialog is a simple Dialog with an image representing the type of the message (error, warning, etc... take a look at `MessageType`), the message text and some Buttons to let the user decide how to respond to the message. The `ButtonsType` enumeration can be used to choose among some common combination of Buttons, but you can also add other Buttons via the usual Dialog's `addButton()` method.

  Optionally you can provide a secondary text that displays more information about the message. Both the main message and the secondary text can be formatted with Pango markup.

  In most cases, MessageDialog is a modal Dialog that you will show with the `run()` method, and `hide()` once the user has responded to it, much like in the following example:

       // create the Dialog
       MessageDialog dialog = new MessageDialog(window, true, MessageType.WARNING, ButtonsType.OK_CANCEL,
               "Do you want to delete file.txt?");
       dialog.setSecondaryText("If you delete that file, you will loose all the information there");

       // Show the Dialog
       ResponseType choice = dialog.run();

       // Hide it once the user has responded
       dialog.hide();

       // process
       if (choice == ResponseType.OK) {
           // delete the file...
       } else {
           // cancel...
       }

  Since:
    4.0.5
  Author:
    Vreixo Formoso
  See Also:
    `MessageType`, `ButtonsType`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.gnome.gtk.Dialog

      `Dialog.Response`

    - ### Nested classes/interfaces inherited from class org.gnome.gtk.Window

      `Window.ConfigureEvent, Window.DeleteEvent`

    - ### Nested classes/interfaces inherited from class org.gnome.gtk.Widget

      `Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MessageDialog(Window parent, boolean modal, MessageType type, ButtonsType buttons, String message)` Create a new MessageDialog.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `getSecondaryUseMarkup()` Whether the secondary text is to be interpreted as marked up with Pango's text markup language.
    `boolean` | `getUseMarkup()` Whether the message text is to be interpreted as marked up with Pango's text markup language.
    `void` | `setImage(Widget image)` Set the Widget to be used as the image for the MessageDialog.
    `void` | `setSecondaryText(String text)` Sets the secondary text for the MessageDialog.
    `void` | `setSecondaryText(String text, boolean markup)` Sets the secondary text for the MessageDialog.
    `void` | `setSecondaryUseMarkup(boolean setting)` Set whether the secondary text is to be parsed as containing markup in Pango's text markup language.
    `void` | `setUseMarkup(boolean setting)` Set whether the message text is to be parsed as containing markup in Pango's text markup language.

    - ### Methods inherited from class org.gnome.gtk.Dialog

      `add, addButton, addButton, addButton, connect, emitResponse, run, setDefaultResponse`

    - ### Methods inherited from class org.gnome.gtk.Window

      `addAcceleratorGroup, connect, connect, getHeight, getMaximized, getPositionX, getPositionY, getScreen, getWidth, move, present, resize, setDecorated, setDefaultSize, setFullscreen, setGravity, setHasResizeGrip, setIcon, setIcon, setKeepAbove, setKeepBelow, setMaximize, setModal, setPosition, setResizable, setSkipPagerHint, setSkipTaskbarHint, setStick, setTitle, setTransientFor, setTypeHint`

    - ### Methods inherited from class org.gnome.gtk.Bin

      `getChild`

    - ### Methods inherited from class org.gnome.gtk.Container

      `getChildren, remove, setBorderWidth`

    - ### Methods inherited from class org.gnome.gtk.Widget

      `activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll`

    - ### Methods inherited from class org.freedesktop.bindings.Pointer

      `toString`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### MessageDialog

          public MessageDialog(Window parent,
                       boolean modal,
                       MessageType type,
                       ButtonsType buttons,
                       String message)

      Create a new MessageDialog.
      Parameters:
        `parent` - Transient parent for the MessageDialog. It can be `null`, but if you have a parent Window you should pass it here to force the Dialog to be on top of the parent Window and to be presented to the user when they select the parent Window.
        `modal` - Whether the Dialog will be modal.
        `type` - Type of the Dialog
        `buttons` - Set of Buttons to be presented.
        `message` - The main message of the Dialog. If you want to use a String formatted with the Pango markup, you will need to call `setUseMarkup()` later.

  - ### Method Detail

    - #### getSecondaryUseMarkup

          public boolean getSecondaryUseMarkup()

      Whether the secondary text is to be interpreted as marked up with Pango's text markup language.

    - #### getUseMarkup

          public boolean getUseMarkup()

      Whether the message text is to be interpreted as marked up with Pango's text markup language. When enabled, the MessageDialog can show formatted text instead of just a simple line of text.

    - #### setImage

          public void setImage(Widget image)

      Set the Widget to be used as the image for the MessageDialog. For common `types`, the image is set to an appropriate icon from the Stock. That is what you must use in most cases. However, there can be some cases where you want to provide your own Widget. In that cases, you should set the message type to `OTHER` when creating the Dialog.

    - #### setSecondaryText

          public void setSecondaryText(String text)

      Sets the secondary text for the MessageDialog. This text is interpreted as plain text, if you want to use Pango markup format you should call `setSecondaryUseMarkup()` or call `setSecondaryText(String, true)` instead.

    - #### setSecondaryText

          public void setSecondaryText(String text,
                              boolean markup)

      Sets the secondary text for the MessageDialog.

      Note that setting a secondary text makes the primary text become bold, unless you are using markup.

      Parameters:
        `text` - The text to be used as secondary text.
        `markup` - Whether to interpret this secondary text as marked up with Pango's text markup language.

    - #### setSecondaryUseMarkup

          public void setSecondaryUseMarkup(boolean setting)

      Set whether the secondary text is to be parsed as containing markup in Pango's text markup language.

    - #### setUseMarkup

          public void setUseMarkup(boolean setting)

      Set whether the message text is to be parsed as containing markup in Pango's text markup language. Using this allows MessageDialog to be created with expressive formatting considerably more advanced than a simple line of text.
      Parameters:
        `setting` - If setting is true, then any markup included in the text is interpreted as such. If its set to false, markup is ignored and included as-is.