getResult() when the dialog is dismissed.
Example:
List<String> colors = List.of("Red", "Yellow", "Green");
ChoiceDialog choiceDialog = new ChoiceDialog<>("Yellow", colors);
choiceDialog.showAndWait();
Dialog
| Modifier and Type | Field and Description |
|---|---|
| private final ComboBox | |
| private final T | |
| private final GridPane | |
| private final Label |
| Access | Constructor and Description |
|---|---|
| public | ChoiceDialog()
Creates a default, empty instance of ChoiceDialog with no set items and a null default choice. |
| public | ChoiceDialog(T
The item to display as the pre-selected choice in the dialog.
This item must be contained within the choices varargs array. defaultChoice, T... All possible choices to present to the user. choices)Creates a new ChoiceDialog instance with the first argument specifying the default choice that should be shown to the user, and all following arguments considered a varargs array of all available choices for the user. |
| public | ChoiceDialog(T
The item to display as the pre-selected choice in the dialog.
This item must be contained within the choices varargs array. defaultChoice, Collection<T> All possible choices to present to the user. choices)Creates a new ChoiceDialog instance with the first argument specifying the default choice that should be shown to the user, and the second argument specifying a collection of all available choices for the user. |
| Modifier and Type | Method and Description |
|---|---|
| public final T | Returns: the default choiceReturns the default choice that was specified in the constructor. |
| public final ObservableList | Returns: the list of all items that will be displayed to usersReturns the list of all items that will be displayed to users. |
| public final T | Returns: the currently selected itemReturns the currently selected item in the dialog. |
| public final ReadOnlyObjectProperty | Returns: the currently selected item propertyReturns the property representing the currently selected item in the dialog. |
| public final void | setSelectedItem(T
The item to select in the dialog. item)Sets the currently selected item in the dialog. |
| private void |
| comboBox | back to summary |
|---|---|
| private final ComboBox<T> comboBox | |
| defaultChoice | back to summary |
|---|---|
| private final T defaultChoice | |
| grid | back to summary |
|---|---|
| private final GridPane grid | |
| label | back to summary |
|---|---|
| private final Label label | |
| ChoiceDialog | back to summary |
|---|---|
| public ChoiceDialog() Creates a default, empty instance of ChoiceDialog with no set items and a
null default choice. Users of this constructor will subsequently need to
call | |
| ChoiceDialog | back to summary |
|---|---|
| public ChoiceDialog(T defaultChoice, T... choices) Creates a new ChoiceDialog instance with the first argument specifying the default choice that should be shown to the user, and all following arguments considered a varargs array of all available choices for the user. It is expected that the defaultChoice be one of the elements in the choices varargs array. If this is not true, then defaultChoice will be set to null and the dialog will show with the initial choice set to the first item in the list of choices.
| |
| ChoiceDialog | back to summary |
|---|---|
| public ChoiceDialog(T defaultChoice, Collection<T> choices) Creates a new ChoiceDialog instance with the first argument specifying the default choice that should be shown to the user, and the second argument specifying a collection of all available choices for the user. It is expected that the defaultChoice be one of the elements in the choices collection. If this is not true, then defaultChoice will be set to null and the dialog will show with the initial choice set to the first item in the list of choices.
| |
| getDefaultChoice | back to summary |
|---|---|
| public final T getDefaultChoice() Returns the default choice that was specified in the constructor.
| |
| getItems | back to summary |
|---|---|
| public final ObservableList Returns the list of all items that will be displayed to users. This list can be modified by the developer to add, remove, or reorder the items to present to the user.
| |
| getSelectedItem | back to summary |
|---|---|
| public final T getSelectedItem() Returns the currently selected item in the dialog.
| |
| selectedItemProperty | back to summary |
|---|---|
| public final ReadOnlyObjectProperty Returns the property representing the currently selected item in the dialog.
| |
| setSelectedItem | back to summary |
|---|---|
| public final void setSelectedItem(T item) Sets the currently selected item in the dialog.
| |
| updateGrid | back to summary |
|---|---|
| private void updateGrid() | |