org.eclipse.swt.widgets
Class MessageBox

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Dialog
              |
              +--org.eclipse.swt.widgets.MessageBox
All Implemented Interfaces:
Drawable, Runnable

public class MessageBox
extends Dialog

Instances of this class are used to display informational or error messages.

Styles:
ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING
OK, OK|CANCEL, YES|NO, YES|NO|CANCEL, RETRY|CANCEL, ABORT|RETRY|IGNORE
Events:
(none)

Note: Only one of the styles ICON_xxx may be specified.


Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Dialog
exitcode
 
Fields inherited from class org.eclipse.swt.widgets.Widget
h, INCMD_DISPOSE, INCMD_EXTKEY, INCMD_KEY, INCMD_LDOWN, INCMD_LUP, INCMD_MENU, INCMD_POS, UPDATEITEM_ENABLED, UPDATEITEM_NAME, w, x, y
 
Constructor Summary
MessageBox(Shell parent)
          Constructs a new instance of this class given only its parent.
MessageBox(Shell parent, int style)
          Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 int open()
          Makes the dialog visible and brings it to the front of the display.
 void setMessage(String message)
          Set the message of the MessageBox.
 
Methods inherited from class org.eclipse.swt.widgets.Dialog
getParent, getStyle, setText
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addListener, computeSize, dispose, focusState, getBorderWidth, getDisplayArea, getSelection, getText, isDisposed, removeListener, setBounds, setCursor, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, toString
 
Methods inherited from interface java.lang.Runnable
run
 
Methods inherited from interface org.eclipse.swt.graphics.Drawable
drawLine, drawRect, drawText, setColor
 

Constructor Detail

MessageBox

public MessageBox(Shell parent)
Constructs a new instance of this class given only its parent.

Parameters:
parent - a shell which will be the parent of the new instance
Throws:
IllegalArgumentException -
SWTException -

MessageBox

public MessageBox(Shell parent,
                  int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a shell which will be the parent of the new instance
Throws:
IllegalArgumentException -
SWTException -
Method Detail

open

public int open()
Makes the dialog visible and brings it to the front of the display.

Returns:
a string describing the absolute path of the first selected file, or null if the dialog was cancelled or an error occurred
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the dialog has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog

setMessage

public void setMessage(String message)
Set the message of the MessageBox.

Parameters:
message - the message to be displayed while the dialog is visible