Dialog - Reference Documentation
Class implementing simple user dialogs for scripts
Index of Methods
Properties
Type | Name | Description |
---|---|---|
java.swing.JFrame | frame | The parent for dialogs |
prompt()
Prototype
String prompt(message)
String prompt(message, defaultValue)
String prompt(message, defaultValue, selectionList)
String prompt(message, defaultValue, selectionList, fileFilter)
Description
Show a modal dialog and prompt user to enter or select a value.
The variant with a single argument shows the message and allows the user to press "OK" or "Cancel".
Specifying a default value allows the user to enter some data.
Specifying a default value "*" allows the user to enter a PIN or password. The PIN or password entered is returned as String. For enhanced security use "**" as default values in which case the resulting PIN or password is returned as ByteString. The ByteString can be zeroized using the clear() method after the entered value has been processed.
A selection list extends the text entry with a drop-down list of possible options. The user may still enter a different value.
Specifying a file filter will create a "Browse..." button that allows the user to pick a name from a file selection dialog. Selection of files and directories are allowed.
The file filter can be specified as regular expression ("/.*\.txt/") or simple file extension (e.g. "txt", ".txt" or "*.txt").
The file filter is only applied to file names, but not to directories.
When a file filter is specified, the selectionList parameter may be null.
The message argument may be plain text or well formed HTML code.
If the user aborts the dialog, then null is returned.
Arguments
Type | Name | Description |
---|---|---|
String
|
message | The text to display in the dialog |
String
|
defaultValue | The value to preset the input field with |
String[]
|
selectionList | List of values the user may select from or null |
String
|
fileFilter | File filter for file selection dialog |
Return
String
|
The value "OK" or the entered value or null if cancel was pressed |
Exceptions
Name | Value | Description |
---|---|---|
GPError | GPError.ARGUMENTS_MISSING | Too few arguments in call |
GPError | GPError.INVALID_ARGUMENTS | Too many arguments in call |
GPError | GPError.INVALID_TYPE | Type of argument is invalid for call |
Example
var s = Dialog.prompt("Hello World. Press OK"); assert(s == "OK"); var s = Dialog.prompt("Hello World. Press CANCEL"); assert(s == null); var s = Dialog.prompt("Hello World. Enter 'OK'", ""); assert(s == "OK"); var s = Dialog.prompt("Enter password and press 'OK'", "*"); assert(typeof(s) == "string"); var s = Dialog.prompt("Enter password and press 'OK'", "**"); assert(s instanceof ByteString); var s = Dialog.prompt("Hello World. Press CANCEL", ""); assert(s == null); var s = Dialog.prompt("<html><p>Hello World.</p><p>Enter <b>'OK'</b></p></html>", "This is a very long text to see if all of it is displayed correctly. Replace this with 'OK'"); assert(s == "OK"); var s = Dialog.prompt("Hello World. Select 'OK'", "", ["A", "OK", "C"]); assert(s == "OK"); var s = Dialog.prompt("Hello World. Select 'OK'", "Not OK", ["A", "OK", "C"]); assert(s == "OK"); var s = Dialog.prompt("Hello World. Select a file", "c:/tmp", null, "*.txt"); assert(s != null); print("Selected File : " + s); var s = Dialog.prompt("Hello World. Press CANCEL", "c:/tmp", null, "*.txt"); assert(s == null); var s = Dialog.prompt("Hello World. Select a file", "", ["c:/tmp", "d:/tmp"], "*.txt"); assert(s != null); print("Selected File : " + s); var s = Dialog.prompt("Hello World. Select a file", "", ["c:/tmp", "d:/tmp"], "/.*\.txt/"); assert(s != null); print("Selected File : " + s);
© Copyright 2003 - 2013 CardContact Software & System Consulting, Minden, Germany