Package de.gmxhome.conrad.jpos.jpos_base
Class SynchronizedMessageBox
java.lang.Object
de.gmxhome.conrad.jpos.jpos_base.SynchronizedMessageBox
Helper class to create message boxes from any thread that are synchronized with the current thread. Option dialogs
as well as simple message boxes can be created that way.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Method to abort the dialog.int
synchronizedConfirmationBox(String message, String title, String[] options, String defaultOption, int messageType, int timeout)
Create a confirmation message box and wait until one option has been selected or a timeout occurs.synchronizedInputBox(String message, String title, String[] options, String defaultOption, int messageType, int timeout)
Create an input message box and wait until input has been finished or a timeout occurs.
-
Field Details
-
Result
Confirmation result. Is null while confirmation dialog has not been finished. If not null, it holds the index of the selected option, starting at zero. -2 in case of timeout, -1 in case of a stop via abortDialog or no selection. Keep in mind: -1 is equal to CLOSE_OPTION.
-
-
Constructor Details
-
SynchronizedMessageBox
public SynchronizedMessageBox()
-
-
Method Details
-
synchronizedConfirmationBox
public int synchronizedConfirmationBox(String message, String title, String[] options, String defaultOption, int messageType, int timeout)Create a confirmation message box and wait until one option has been selected or a timeout occurs. If at least one option has been specified, defaultOption must be equal to one of the given options. Otherwise, defaultOption can be null to specify a default optionType of DEFAULT_OPTION or a string representation of one of YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION.- Parameters:
message
- Message to be displayed.title
- Message box title.options
- Options to be presented, null for simple message boxes.defaultOption
- The default option.messageType
- JOptionPane message type.timeout
- timeout in milliseconds. If ≤ 0, no timeout handling will occur.- Returns:
- If timeout occurred, CLOSED_OPTION - 1. If box has been close by user or via AbortDialog, CLOSED_OPTION. If options is null, YES_OPTION, NO_OPTION or CANCEL_OPTION. If option is array of String, the index of the selected option.
-
synchronizedInputBox
public String synchronizedInputBox(String message, String title, String[] options, String defaultOption, int messageType, int timeout)Create an input message box and wait until input has been finished or a timeout occurs. If at least one option has been specified, a combo box containing the options as selectable input will be generated. Otherwise, a text field can be filled.- Parameters:
message
- Message to be displayed.title
- Message box title.options
- Options for combo box or null for simple input field.defaultOption
- The default value.messageType
- JOptionPane message type.timeout
- timeout in milliseconds. If ≤ 0, no timeout handling will occur.- Returns:
- The selected or entered input value or null in case of cancellation or timeout.
-
abortDialog
public void abortDialog()Method to abort the dialog.
-