Class SwingMessageOutput
- java.lang.Object
-
- net.sf.jguiraffe.gui.platform.swing.builder.utils.SwingMessageOutput
-
- All Implemented Interfaces:
net.sf.jguiraffe.gui.builder.utils.MessageOutput
public class SwingMessageOutput extends Object implements net.sf.jguiraffe.gui.builder.utils.MessageOutput
A Swing specific implementation of the
MessageOutputinterface.This implementation makes use of
JOptionPanefor displaying message boxes.- Version:
- $Id: SwingMessageOutput.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Field Summary
Fields Modifier and Type Field Description static intNO_LINE_WRAPConstant for a line length which disables line wrapping.
-
Constructor Summary
Constructors Constructor Description SwingMessageOutput()Creates a new instance ofSwingMessageOutputand sets a default maximum line length.SwingMessageOutput(int maxLineLength)Creates a new instance ofSwingMessageOutputwith the specified maximum message line length.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intconvertButtonType(int type)Converts the passed in button type into the corresponding option type used byJOptionPane.protected intconvertMessageType(int type)Converts the passed in message type into the corresponding type used byJOptionPane.protected intconvertReturnValue(int value)Converts the passed in return value from theJOptionPaneto the correspondingRET_XXXXconstant.protected JDialogcreateDialog(JOptionPane pane, net.sf.jguiraffe.gui.builder.window.Window parent, String title)Creates the dialog from the option pane.protected JOptionPanecreateOptionPane(net.sf.jguiraffe.gui.builder.window.Window parent, Object message, String title, int messageType, int optionType)Creates the option pane dialog for displaying the message box.intgetMaximumLineLength()Returns the maximum line length for the messages to be displayed.intshow(net.sf.jguiraffe.gui.builder.window.Window parent, Object message, String title, int messageType, int buttonType)Displays a message box.protected ObjectshowPane(JOptionPane pane, JDialog dialog)Displays the given option pane.
-
-
-
Field Detail
-
NO_LINE_WRAP
public static final int NO_LINE_WRAP
Constant for a line length which disables line wrapping. If this value is passed to the constructor, the message text is not wrapped into multiple lines.- Since:
- 1.3
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SwingMessageOutput
public SwingMessageOutput()
Creates a new instance ofSwingMessageOutputand sets a default maximum line length.
-
SwingMessageOutput
public SwingMessageOutput(int maxLineLength)
Creates a new instance ofSwingMessageOutputwith 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 valueNO_LINE_WRAPcan be passed.- Parameters:
maxLineLength- the maximum length of a line for the message text (in characters); must be > 0- Throws:
IllegalArgumentException- if an invalid line length is passed in- Since:
- 1.3
-
-
Method Detail
-
getMaximumLineLength
public int getMaximumLineLength()
Returns the maximum line length for the messages to be displayed.- Returns:
- the maximum line length
- Since:
- 1.3
-
show
public int show(net.sf.jguiraffe.gui.builder.window.Window parent, Object message, String title, int messageType, int buttonType)Displays a message box.- Specified by:
showin interfacenet.sf.jguiraffe.gui.builder.utils.MessageOutput- Parameters:
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 displayed- Returns:
- the pressed button
-
convertMessageType
protected int convertMessageType(int type)
Converts the passed in message type into the corresponding type used byJOptionPane.- Parameters:
type- the type to be converted- Returns:
- the corresponding Swing constant
-
convertButtonType
protected int convertButtonType(int type)
Converts the passed in button type into the corresponding option type used byJOptionPane.- Parameters:
type- the type to be converted- Returns:
- the corresponding Swing constant
-
convertReturnValue
protected int convertReturnValue(int value)
Converts the passed in return value from theJOptionPaneto the correspondingRET_XXXXconstant.- Parameters:
value- the return value from the option pane- Returns:
- the corresponding
RET_XXXXconstant
-
createOptionPane
protected JOptionPane createOptionPane(net.sf.jguiraffe.gui.builder.window.Window parent, Object message, String title, int messageType, int optionType)
Creates the option pane dialog for displaying the message box.- Parameters:
parent- the parent windowmessage- the messagetitle- the titlemessageType- the message typeoptionType- the option type- Returns:
- the option pane
-
showPane
protected Object showPane(JOptionPane pane, JDialog dialog)
Displays the given option pane. This method is called after the pane has been created and initialized.- Parameters:
pane- the pane to displaydialog- the dialog obtained from the option pane- Returns:
- the return value of the pane (indicating the option selected by the user)
-
createDialog
protected JDialog createDialog(JOptionPane pane, net.sf.jguiraffe.gui.builder.window.Window parent, String title)
Creates the dialog from the option pane. This is the component that is to be displayed.- Parameters:
pane- the option paneparent- the parent componenttitle- the dialog's title- Returns:
- the dialog to display
-
-