public class SwingMessageOutput extends Object implements MessageOutput
A Swing specific implementation of the MessageOutput
interface.
This implementation makes use of JOptionPane
for displaying
message boxes.
Modifier and Type | Field and Description |
---|---|
static int |
NO_LINE_WRAP
Constant for a line length which disables line wrapping.
|
BTN_OK, BTN_OK_CANCEL, BTN_YES_NO, BTN_YES_NO_CANCEL, MESSAGE_ERROR, MESSAGE_INFO, MESSAGE_PLAIN, MESSAGE_QUESTION, MESSAGE_WARNING, RET_CANCEL, RET_NO, RET_OK, RET_YES
Constructor and Description |
---|
SwingMessageOutput()
Creates a new instance of
SwingMessageOutput and sets a default
maximum line length. |
SwingMessageOutput(int maxLineLength)
Creates a new instance of
SwingMessageOutput with the specified
maximum message line length. |
Modifier and Type | Method and Description |
---|---|
protected int |
convertButtonType(int type)
Converts the passed in button type into the corresponding option type
used by
JOptionPane . |
protected int |
convertMessageType(int type)
Converts the passed in message type into the corresponding type used by
JOptionPane . |
protected int |
convertReturnValue(int value)
Converts the passed in return value from the
JOptionPane
to the corresponding RET_XXXX constant. |
protected JDialog |
createDialog(JOptionPane pane,
Window parent,
String title)
Creates the dialog from the option pane.
|
protected JOptionPane |
createOptionPane(Window parent,
Object message,
String title,
int messageType,
int optionType)
Creates the option pane dialog for displaying the message box.
|
int |
getMaximumLineLength()
Returns the maximum line length for the messages to be displayed.
|
int |
show(Window parent,
Object message,
String title,
int messageType,
int buttonType)
Displays a message box.
|
protected Object |
showPane(JOptionPane pane,
JDialog dialog)
Displays the given option pane.
|
public static final int NO_LINE_WRAP
public SwingMessageOutput()
SwingMessageOutput
and sets a default
maximum line length.public SwingMessageOutput(int maxLineLength)
SwingMessageOutput
with the specified
maximum message line length. Before the message is displayed, it is
ensured that single lines do not exceed this maximum length; if
necessary, the text is split into multiple lines. To disable line
wrapping, the value NO_LINE_WRAP
can be passed.maxLineLength
- the maximum length of a line for the message text
(in characters); must be > 0IllegalArgumentException
- if an invalid line length is passed inpublic int getMaximumLineLength()
public int show(Window parent, Object message, String title, int messageType, int buttonType)
show
in interface MessageOutput
parent
- the parent window; this should be null or point to
a Swing windowmessage
- the messagetitle
- the message box's titlemessageType
- the type of the messagebuttonType
- specifies the buttons to be displayedprotected int convertMessageType(int type)
JOptionPane
.type
- the type to be convertedprotected int convertButtonType(int type)
JOptionPane
.type
- the type to be convertedprotected int convertReturnValue(int value)
JOptionPane
to the corresponding RET_XXXX
constant.value
- the return value from the option paneRET_XXXX
constantprotected JOptionPane createOptionPane(Window parent, Object message, String title, int messageType, int optionType)
parent
- the parent windowmessage
- the messagetitle
- the titlemessageType
- the message typeoptionType
- the option typeprotected Object showPane(JOptionPane pane, JDialog dialog)
pane
- the pane to displaydialog
- the dialog obtained from the option paneprotected JDialog createDialog(JOptionPane pane, Window parent, String title)
pane
- the option paneparent
- the parent componenttitle
- the dialog's titleCopyright © 2016 The JGUIraffe Team. All rights reserved.