Interface MessageOutput
-
- All Known Implementing Classes:
NullMessageOutput
public interface MessageOutputDefinition of an interface for creating message boxes in a platform independent way.
This interface defines a main
show()method to display a message box of a pre-defined type. The type is specified using one of the the constants defined by this interface. The method expects a title (as string) and an object representing the message to be displayed. From this object thetoString()is called in order to obtain the message text to be displayed. Concrete implementations have to implement a certain amount of processing on the message text:- The character '\n' should cause a newline in the message. That way messages with multiple lines can be created.
- A reasonable line wrapping should be performed to prevent that the message window becomes too wide or that parts of the message text are cut off.
show()method indicates the pressed button.Note that the
show()method must be called in the UI thread! It lies in the responsibility of the caller to use the currentGUISynchronizerto ensure that the invocation happens in the correct thread.Concrete implementations will map the functionality provided by this interface to GUI library specific classes. A Swing related implementation for instance could use Swing's
JOptionPaneto provide the required functionality.- Version:
- $Id: MessageOutput.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Field Summary
Fields Modifier and Type Field Description static intBTN_OKConstant for the button type OK.static intBTN_OK_CANCELConstant for the button type OK, CANCEL.static intBTN_YES_NOConstant for the button type YES, NO.static intBTN_YES_NO_CANCELConstant for the button type YES, NO, CANCEL.static intMESSAGE_ERRORConstant for the message type ERROR.static intMESSAGE_INFOConstant for the message type INFO.static intMESSAGE_PLAINConstant for the message type PLAIN.static intMESSAGE_QUESTIONConstant for the message type QUESTION.static intMESSAGE_WARNINGConstant for the message type WARNING.static intRET_CANCELConstant for the return value CANCEL.static intRET_NOConstant for the return value NO.static intRET_OKConstant for the return value OK.static intRET_YESConstant for the return value YES.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intshow(Window parent, Object message, String title, int messageType, int buttonType)Displays a message box based on the given options.
-
-
-
Field Detail
-
MESSAGE_ERROR
static final int MESSAGE_ERROR
Constant for the message type ERROR.- See Also:
- Constant Field Values
-
MESSAGE_INFO
static final int MESSAGE_INFO
Constant for the message type INFO.- See Also:
- Constant Field Values
-
MESSAGE_WARNING
static final int MESSAGE_WARNING
Constant for the message type WARNING.- See Also:
- Constant Field Values
-
MESSAGE_QUESTION
static final int MESSAGE_QUESTION
Constant for the message type QUESTION.- See Also:
- Constant Field Values
-
MESSAGE_PLAIN
static final int MESSAGE_PLAIN
Constant for the message type PLAIN.- See Also:
- Constant Field Values
-
BTN_OK
static final int BTN_OK
Constant for the button type OK.- See Also:
- Constant Field Values
-
BTN_OK_CANCEL
static final int BTN_OK_CANCEL
Constant for the button type OK, CANCEL.- See Also:
- Constant Field Values
-
BTN_YES_NO
static final int BTN_YES_NO
Constant for the button type YES, NO.- See Also:
- Constant Field Values
-
BTN_YES_NO_CANCEL
static final int BTN_YES_NO_CANCEL
Constant for the button type YES, NO, CANCEL.- See Also:
- Constant Field Values
-
RET_OK
static final int RET_OK
Constant for the return value OK.- See Also:
- Constant Field Values
-
RET_CANCEL
static final int RET_CANCEL
Constant for the return value CANCEL.- See Also:
- Constant Field Values
-
RET_YES
static final int RET_YES
Constant for the return value YES. Note that this value is identical to theRET_OKreturn value. This is analogous to Swing.- See Also:
- Constant Field Values
-
RET_NO
static final int RET_NO
Constant for the return value NO.- See Also:
- Constant Field Values
-
-
Method Detail
-
show
int show(Window parent, Object message, String title, int messageType, int buttonType)
Displays a message box based on the given options. Please refer to the class comment for further details about the parameters and how they are interpreted.- Parameters:
parent- the parent windowmessage- the message itself; can be an arbitrary object whosetoString()method will be used to obtain the text to be displayedtitle- the message box's titlemessageType- the type of the message; this must be one theMESSAGE_XXXXconstantsbuttonType- defines the buttons to be displayed; this must be one of theBTN_XXXXconstants- Returns:
- a flag for the button pressed by the user; this will be one of
the
RET_XXXXconstants
-
-