Class FileDialogOption

java.lang.Object
com.codename1.io.filechooser.FileDialogOption

public final class FileDialogOption extends Object

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).

  • Field Details

    • TYPE_CHECKBOX

      public static final int TYPE_CHECKBOX
      A checkbox. Its value is "true" or "false".
      See Also:
    • TYPE_CHOICE

      public static final int TYPE_CHOICE
      A choice list. Its value is the selected choice.
      See Also:
    • TYPE_TEXT

      public static final int TYPE_TEXT
      A free text field.
      See Also:
  • Method Details

    • checkbox

      public static FileDialogOption checkbox(String id, String label, boolean checked)

      Creates a checkbox option.

      Parameters
      • id: the key its value is reported under
      • label: the checkbox text
      • checked: 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: the key its value is reported under
      • label: the label shown beside the list
      • choices: the entries
      Returns

      the option

    • text

      public static FileDialogOption text(String id, String label, String value)

      Creates a text field option.

      Parameters
      • id: the key its value is reported under
      • label: the label shown beside the field
      • value: 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: 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