Next: , Previous: , Up: Java Interface   [Contents][Index]


37.2 Dialog Box Functions

The following functions all use the Java Interface to provide some form of dialog box.

Function File: h = msgbox (msg)
Function File: h = msgbox (msg, title)
Function File: h = msgbox (msg, title, icon)
Function File: h = msgbox (…, createmode)

Display msg using a message dialog box.

The message may have multiple lines separated by newline characters ("\n"), or it may be a cellstr array with one element for each line.

The optional input title (character string) can be used to decorate the dialog caption.

The optional argument icon selects a dialog icon. It can be one of "none" (default), "error", "help", or "warn".

The return value is always 1.

Compatibility Note: The optional argument createmode is accepted for MATLAB compatibility, but is not implemented.

See also: errordlg, helpdlg, inputdlg, listdlg, questdlg, warndlg.

Function File: h = errordlg (msg)
Function File: h = errordlg (msg, title)
Function File: h = errordlg (msg, title, createmode)

Display msg using an error dialog box.

The message may have multiple lines separated by newline characters ("\n"), or it may be a cellstr array with one element for each line.

The optional input title (character string) can be used to set the dialog caption. The default title is "Error Dialog".

The return value is always 1.

Compatibility Note: The optional argument createmode is accepted for MATLAB compatibility, but is not implemented.

See also: helpdlg, inputdlg, listdlg, msgbox, questdlg, warndlg.

Function File: h = helpdlg (msg)
Function File: h = helpdlg (msg, title)

Display msg in a help dialog box.

The message may have multiple lines separated by newline characters ("\n"), or it may be a cellstr array with one element for each line.

The optional input title (character string) can be used to set the dialog caption. The default title is "Help Dialog".

The return value is always 1.

See also: errordlg, inputdlg, listdlg, msgbox, questdlg, warndlg.

Function File: cstr = inputdlg (prompt)
Function File: cstr = inputdlg (prompt, title)
Function File: cstr = inputdlg (prompt, title, rowscols)
Function File: cstr = inputdlg (prompt, title, rowscols, defaults)

Return user input from a multi-textfield dialog box in a cell array of strings, or an empty cell array if the dialog is closed by the Cancel button.

Inputs:

prompt

A cell array with strings labeling each text field. This input is required.

title

String to use for the caption of the dialog. The default is "Input Dialog".

rowscols

Specifies the size of the text fields and can take three forms:

  1. a scalar value which defines the number of rows used for each text field.
  2. a vector which defines the individual number of rows used for each text field.
  3. a matrix which defines the individual number of rows and columns used for each text field. In the matrix each row describes a single text field. The first column specifies the number of input rows to use and the second column specifies the text field width.
defaults

A list of default values to place in each text fields. It must be a cell array of strings with the same size as prompt.

See also: errordlg, helpdlg, listdlg, msgbox, questdlg, warndlg.

Function File: [sel, ok] = listdlg (key, value, …)

Return user inputs from a list dialog box in a vector of selection indices sel and a flag ok indicating how the user closed the dialog box.

The value of ok is 1 if the user closed the box with the OK button, otherwise it is 0 and sel is empty.

The indices in sel are 1-based.

The arguments are specified in form of key, value pairs. The "ListString" argument pair must be specified.

Valid key and value pairs are:

"ListString"

a cell array of strings comprising the content of the list.

"SelectionMode"

can be either "Single" or "Multiple" (default).

"ListSize"

a vector with two elements width and height defining the size of the list field in pixels. Default is [160 300].

"InitialValue"

a vector containing 1-based indices of preselected elements. Default is 1 (first item).

"Name"

a string to be used as the dialog caption. Default is "".

"PromptString"

a cell array of strings to be displayed above the list field. Default is {}.

"OKString"

a string used to label the OK button. Default is "OK".

"CancelString"

a string used to label the Cancel button. Default is "Cancel".

Example:

[sel, ok] = listdlg ("ListString", {"An item", "another", "yet another"},
                     "SelectionMode", "Multiple");
if (ok == 1)
  for i = 1:numel (sel)
    disp (sel(i));
  endfor
endif

See also: menu, errordlg, helpdlg, inputdlg, msgbox, questdlg, warndlg.

Function File: btn = questdlg (msg)
Function File: btn = questdlg (msg, title)
Function File: btn = questdlg (msg, title, default)
Function File: btn = questdlg (msg, title, btn1, btn2, default)
Function File: btn = questdlg (msg, title, btn1, btn2, btn3, default)

Display msg using a question dialog box and return the caption of the activated button.

The dialog may contain two or three buttons which will all close the dialog.

The message may have multiple lines separated by newline characters ("\n"), or it may be a cellstr array with one element for each line.

The optional title (character string) can be used to decorate the dialog caption.

The string default identifies the default button, which is activated by pressing the ENTER key. It must match one of the strings given in btn1, btn2, or btn3.

If only msg and title are specified, three buttons with the default captions "Yes", "No", and "Cancel" are used.

If only two button captions, btn1 and btn2, are specified the dialog will have only these two buttons.

See also: errordlg, helpdlg, inputdlg, listdlg, warndlg.

Function File: h = warndlg (msg)
Function File: h = warndlg (msg, title)
Function File: h = warndlg (msg, title, createmode)

Display msg using a warning dialog box.

The message may have multiple lines separated by newline characters ("\n"), or it may be a cellstr array with one element for each line.

The optional input title (character string) can be used to set the dialog caption. The default title is "Warning Dialog".

The return value is always 1.

Compatibility Note: The optional argument createmode is accepted for MATLAB compatibility, but is not implemented.

See also: helpdlg, inputdlg, listdlg, questdlg.


Next: , Previous: , Up: Java Interface   [Contents][Index]