Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class FileDialogOption

  1. Object
  2. FileDialogOption

A declarative control added to a native file dialog: a checkbox, a choice list or a text field.

This is the portable way to customize a dialog. Each desktop maps it to its own widgets (an accessory view on macOS, IFileDialogCustomize on Windows, gtk_file_chooser_add_choice on Linux, a Swing accessory in the simulator), and the fallback chooser renders it with Codename One components. Mobile pickers have a fixed UI and ignore options; check FileDialogFeatures#OPTIONS before relying on them. The value the user chose is read back from FileDialogResult#getOptionValue(String).

Fields

public static final int TYPE_CHECKBOX = 1A checkbox.
public static final int TYPE_CHOICE = 2A choice list.
public static final int TYPE_TEXT = 3A free text field.

Methods

public static FileDialogOption checkbox(String id, String label, boolean checked)Creates a checkbox option.
public static FileDialogOption choice(String id, String label, String... choices)Creates a choice list option.
public static FileDialogOption text(String id, String label, String value)Creates a text field option.
public FileDialogOption defaultValue(String value)Changes the initial value; for a choice it must be one of the choices.
public String getId()The key the value is reported under.
public int getType()One of #TYPE_CHECKBOX, #TYPE_CHOICE or #TYPE_TEXT.
public String getLabel()The text shown for the control.
public String[] getChoices()The entries of a choice option, empty for other types.
public String getDefaultValue()The initial value.

Inherited methods

Field details

TYPE_CHECKBOX

public static final int TYPE_CHECKBOX = 1
A checkbox. Its value is "true" or "false".

TYPE_CHOICE

public static final int TYPE_CHOICE = 2
A choice list. Its value is the selected choice.

TYPE_TEXT

public static final int TYPE_TEXT = 3
A free text field.

Method details

checkbox

public static FileDialogOption checkbox(String id, String label, boolean checked)
Creates a checkbox option.

Parameters

id String
the key its value is reported under
label String
the checkbox text
checked boolean
the initial state

Returns

the option

choice

public static FileDialogOption choice(String id, String label, String... choices)
Creates a choice list option. The first choice is selected initially.

Parameters

id String
the key its value is reported under
label String
the label shown beside the list
choices String...
the entries

Returns

the option

text

public static FileDialogOption text(String id, String label, String value)
Creates a text field option.

Parameters

id String
the key its value is reported under
label String
the label shown beside the field
value String
the initial text

Returns

the option

defaultValue

public FileDialogOption defaultValue(String value)
Changes the initial value; for a choice it must be one of the choices.

Parameters

value String
the initial value

Returns

this option

getId

public String getId()
The key the value is reported under.

Returns

the id

getType

public int getType()
One of #TYPE_CHECKBOX, #TYPE_CHOICE or #TYPE_TEXT.

Returns

the type

getLabel

public String getLabel()
The text shown for the control.

Returns

the label

getChoices

public String[] getChoices()
The entries of a choice option, empty for other types.

Returns

a copy of the choices

getDefaultValue

public String getDefaultValue()
The initial value.

Returns

the initial value