org.gnu.gtk
Class Dialog

java.lang.Object
  extended by org.gnu.glib.Struct
      extended by org.gnu.glib.GObject
          extended by org.gnu.gtk.GtkObject
              extended by org.gnu.gtk.Widget
                  extended by org.gnu.gtk.Container
                      extended by org.gnu.gtk.Bin
                          extended by org.gnu.gtk.Window
                              extended by org.gnu.gtk.Dialog
Direct Known Subclasses:
AboutDialog, ColorSelectionDialog, FileChooserDialog, FileSelection, FontSelectionDialog, InputDialog, MessageDialog

public class Dialog
extends Window

Dialog boxes are a convenient way to prompt the user for a small amount of input, to display a message, ask a question, or anything else that does not require extensive effort on the user's part.

GTK+ treats a dialog as a window split vertically. The top section is a VBox, and is where widgets such as a Label or a Entry should be packed. The bottom area is known as the actionArea. This is generally used for packing buttons into the dialog which may perform functions such as cancel, ok, or apply. The two areas are separated by a HSeparator.

A 'modal' dialog (that is, one which freezes the rest of the application from user input), can be created by calling Window.setModal(boolean) on the dialog.

If you want to block waiting for a dialog to return before returning control flow to your code, you can call run(). This function enters a recursive main loop and waits for the user to respond to the dialog, returning the response ID corresponding to the button the user clicked.


Constructor Summary
Dialog()
          Construct a new Dialog object
Dialog(org.gnu.glib.Handle handle)
          Construct a dialog using a handle to a native resource.
 
Method Summary
 void addButton(GtkStockItem stockItem, int responseId)
          Adds a button with the given stock button and sets things up so that clicking the button will emit the "response" event with the given responseId.
 void addButton(java.lang.String buttonText, int responseId)
          Adds a button with the given text and sets things up so that clicking the button will emit the "response" event with the given responseId.
 void addListener(DialogListener listener)
          Register an object to handle dialog events.
 void addWidget(Widget child, int responseId)
          Adds an activatable widget to the action area of the Dialog, connecting a signal handler that will emit the "response" signal on the dialog when the widget is activated.
 HButtonBox getActionArea()
          The lower area of the Dialog where the buttons are located is a HButtonBox.
static Dialog getDialog(org.gnu.glib.Handle handle)
          Internal static factory method to be used by Java-Gnome only.
 VBox getDialogLayout()
          The upper area of the Dialog where widgets can be added is a VBox.
 java.lang.Class getEventListenerClass(java.lang.String signal)
           
 EventType getEventType(java.lang.String signal)
           
 boolean getHasSeparator()
          Access for whether the dialog has a separator.
 ResponseType getResponseForWidget(Widget widget)
          Gets the response id of a widget in the action area of a dialog.
static Type getType()
          Retrieve the runtime type used by the GLib library.
 void removeListener(DialogListener listener)
          Removes a listener
 int run()
          Blocks in a recursive main loop until the dialog either emits a response signal or is destroyed.
 void setDefaultResponse(int responseId)
          Sets the last widget in the dialog's action area with the given responseId as the default widget for the dialog.
 void setHasSeparator(boolean setting)
          Sets whether the dialog has a separator above the buttons.
 
Methods inherited from class org.gnu.gtk.Window
addAccelGroup, deiconify, destroy, fullscreen, getAcceptFocus, getDefaultIconList, getFocusOnMap, getFocusWidget, getGravity, getIcon, getIconList, getIconName, getPosition, getScreen, getSize, getSkipPagerHint, getSkipTaskbarHint, getTitle, getTransientParent, getWindow, hasToplevelFocus, iconify, isActive, isDestroyed, listToplevelWindows, maximize, move, present, removeAccelGroup, resize, setAcceptFocus, setAutoStartupNotification, setDecorated, setDefaultIcon, setDefaultIconFromFile, setDefaultIconList, setDefaultIconName, setDefaultSize, setDefaultWidget, setFocusOnMap, setFocusWidget, setGeometryHints, setGravity, setIcon, setIconFromFile, setIconList, setIconName, setKeepAbove, setKeepBelow, setModal, setPosition, setResizable, setScreen, setSkipPagerHint, setSkipTaskbarHint, setTitle, setTransientParent, stick, unfullscreen, unmaximize, unstick
 
Methods inherited from class org.gnu.gtk.Bin
getChild
 
Methods inherited from class org.gnu.gtk.Container
add, addListener, getBooleanChildProperty, getBorderWidth, getChildProperty, getChildren, getIntChildProperty, getResizeMode, remove, removeListener, resizeChildren, setBooleanChildProperty, setBorderWidth, setChildProperty, setIntChildProperty, setResizeMode
 
Methods inherited from class org.gnu.gtk.Widget
activate, addAccelerator, addEvents, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, canActivateAccel, createContext, createLayout, draw, drawArea, drawArea, finish, getAccessible, getAllocation, getCanFocus, getColormap, getContext, getData, getDisplay, getDragData, getExtensionEvents, getModifierStyle, getName, getParent, getParentWindow, getPointer, getRootWindow, getSensitive, getStyle, getToplevel, getWidget, getWindow, grabDefault, grabFocus, hasFocus, hasScreen, hide, hideAll, highlight, highlight, intersect, isAncestor, makeWidget, modifyStyle, popColormap, pushColormap, realize, removeAccelerator, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, reparent, setBackgroundColor, setBaseColor, setCanFocus, setColormap, setDoubleBuffered, setDragDestination, setDragIcon, setDragIconPixbuf, setDragIconStock, setDragSource, setEvents, setExtensionEvents, setFont, setForegroundColor, setMinimumSize, setName, setNoDragDestination, setNoDragSource, setSensitive, setTextColor, shapeCombineMask, show, showAll, unHighlight, unHighlight
 
Methods inherited from class org.gnu.gtk.GtkObject
sink
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, collect, freezeNotify, getBooleanProperty, getData, getDoubleProperty, getFloatProperty, getGObjectFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getPixbufProperty, getProperty, getStringProperty, hasProperty, notify, removeEventHandler, removeListener, setBooleanProperty, setData, setDoubleProperty, setFloatProperty, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify
 
Methods inherited from class org.gnu.glib.Struct
equals, getHandle, getNullHandle, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dialog

public Dialog()
Construct a new Dialog object


Dialog

public Dialog(org.gnu.glib.Handle handle)
Construct a dialog using a handle to a native resource.

Method Detail

getDialog

public static Dialog getDialog(org.gnu.glib.Handle handle)
Internal static factory method to be used by Java-Gnome only.


run

public int run()
Blocks in a recursive main loop until the dialog either emits a response signal or is destroyed. The return value can be compared against a ResponseType to determine if a standard return value is emitted. The developer can also set the response type when a button or widget is added to the dialog. If the dialog is destroyed the run method will return ResponseType.NONE.

Returns:
The response that indicates which button the user pressed or ResponseType.NONE if the window was destroyed.

addButton

public void addButton(java.lang.String buttonText,
                      int responseId)
Adds a button with the given text and sets things up so that clicking the button will emit the "response" event with the given responseId.

Parameters:
buttonText - The text string to display on the button.
responseId - The response ID to emit when the user clicks the button that is to be added.

addButton

public void addButton(GtkStockItem stockItem,
                      int responseId)
Adds a button with the given stock button and sets things up so that clicking the button will emit the "response" event with the given responseId.

Parameters:
stockItem - The stock ID for the button to be added.
responseId - The response ID to emit when the user clicks the button that is to be added.

addWidget

public void addWidget(Widget child,
                      int responseId)
Adds an activatable widget to the action area of the Dialog, connecting a signal handler that will emit the "response" signal on the dialog when the widget is activated. The Widget is appended to the end of the Dialog's action area.

Parameters:
child - An activatable Widget to add to the dialog.
responseId - The response ID to emit when the user clicks the widget.

setDefaultResponse

public void setDefaultResponse(int responseId)
Sets the last widget in the dialog's action area with the given responseId as the default widget for the dialog. Pressing "Enter" normally activates the default widget.

Parameters:
responseId - The response ID.

getDialogLayout

public VBox getDialogLayout()
The upper area of the Dialog where widgets can be added is a VBox. This method will return that layout control.

Returns:
The VBox that is the layout control for the dialog.

getActionArea

public HButtonBox getActionArea()
The lower area of the Dialog where the buttons are located is a HButtonBox. This method will return that container.

Returns:
The HButton box that is known as the action area.

setHasSeparator

public void setHasSeparator(boolean setting)
Sets whether the dialog has a separator above the buttons. This is true by default.

Parameters:
setting - Indicates if a separator should be added to the dialog.

getHasSeparator

public boolean getHasSeparator()
Access for whether the dialog has a separator.

Returns:
true if the Dialog has a separator.

getResponseForWidget

public ResponseType getResponseForWidget(Widget widget)
Gets the response id of a widget in the action area of a dialog.

Parameters:
widget - a widget in the action area of this Dialog.
Returns:
the response id of the widget, or ResponseType.NONE if the widget doesn't have a response id set.

addListener

public void addListener(DialogListener listener)
Register an object to handle dialog events.

See Also:
DialogListener

removeListener

public void removeListener(DialogListener listener)
Removes a listener

See Also:
addListener(org.gnu.gtk.event.DialogListener)

getEventListenerClass

public java.lang.Class getEventListenerClass(java.lang.String signal)
Overrides:
getEventListenerClass in class Container

getEventType

public EventType getEventType(java.lang.String signal)
Overrides:
getEventType in class Container

getType

public static Type getType()
Retrieve the runtime type used by the GLib library.