CheckBox, and the state
of each row can be queried via the check model.
titleProperty() property), with or without an indication of
how many items have been checked (see showCheckedCountProperty() property).
The following screenshot shows the CheckComboBox with some sample data:
The following screenshot shows the CheckComboBox with a fixed title and the
indication of how many items have been checked:
To create the CheckComboBox shown in the screenshot, simply do the following:
// create the data to show in the CheckComboBox
final ObservableList<String> strings = FXCollections.observableArrayList();
for (int i = 0; i <= 100; i++) {
strings.add("Item " + i);
}
// Create the CheckComboBox with the data
final CheckComboBox<String> checkComboBox = new CheckComboBox<String>(strings);
// and listen to the relevant events (e.g. when the selected indices or
// selected items change).
checkComboBox.getCheckModel().getCheckedItems().addListener(new ListChangeListener<String>() {
public void onChanged(ListChangeListener.Change<? extends String> c) {
while(c.next()) {
//do something with changes here
}
System.out.println(checkComboBox.getCheckModel().getCheckedItems());
}
});
}
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private CheckComboBoxSkin | |
| private ObjectProperty | checkModel
Properties |
| public static final String | COMBO_BOX_ROWS_TO_MEASURE_WIDTH_KEY
* Static fields * * |
| private ObjectProperty | |
| private final Map | |
| private final ObservableList | items
Private fields |
| private BooleanProperty | |
| private StringProperty |
| Access | Constructor and Description |
|---|---|
| public | |
| public | CheckComboBox(final ObservableList<T>
The items to display within the CheckComboBox. items)Creates a new CheckComboBox instance with the given items available as choices. |
| Modifier and Type | Method and Description |
|---|---|
| public final ObjectProperty | checkModelProperty()
The check model provides the API through which it is possible to check single or multiple items within a CheckComboBox, as well as inspect which items have been checked by the user. |
| public final ObjectProperty | converterProperty()
A |
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public final IndexedCheckModel | |
| public final StringConverter | getConverter()
A |
| public BooleanProperty | getItemBooleanProperty(int index)
Returns the |
| public BooleanProperty | |
| public ObservableList | getItems()
Represents the list of choices available to the user, from which they can select zero or more items. |
| public final String | Returns: the title if it has been set, null otherwiseThe title set for this control, if it has been set explicitly by the client. |
| public void | |
| public final boolean | isShowCheckedCount()
Returns: whether the checked items count is set to be shown beside a fixed title |
| public final void | setCheckModel(IndexedCheckModel<T> value)
Sets the 'check model' to be used in the CheckComboBox - this is the
code that is responsible for representing the selected state of each
|
| public final void | setConverter(StringConverter<T>
A value)StringConverter that, given an object of type T, will
return a String that can be used to represent the object visually.Sets the |
| public final void | setShowCheckedCount(boolean
the value to set value)Sets the value to use to decide whether the checked items count should be shown or not |
| public final void | |
| public void | |
| public final BooleanProperty | Returns: if the count should be shownA boolean to decide if the information of how many items are checked should be shown beside the fixed title. |
| public final StringProperty |
| checkComboBoxSkin | back to summary |
|---|---|
| private CheckComboBoxSkin<T> checkComboBoxSkin | |
| checkModel | back to summary |
|---|---|
| private ObjectProperty<IndexedCheckModel<T>> checkModel Properties | |
| COMBO_BOX_ROWS_TO_MEASURE_WIDTH_KEY | back to summary |
|---|---|
| public static final String COMBO_BOX_ROWS_TO_MEASURE_WIDTH_KEY * Static fields * * | |
| converter | back to summary |
|---|---|
| private ObjectProperty<StringConverter<T>> converter | |
| itemBooleanMap | back to summary |
|---|---|
| private final Map<T, BooleanProperty> itemBooleanMap | |
| items | back to summary |
|---|---|
| private final ObservableList<T> items Private fields | |
| showCheckedCount | back to summary |
|---|---|
| private BooleanProperty showCheckedCount | |
| title | back to summary |
|---|---|
| private StringProperty title | |
| CheckComboBox | back to summary |
|---|---|
| public CheckComboBox() Creates a new CheckComboBox instance with an empty list of choices. | |
| CheckComboBox | back to summary |
|---|---|
| public CheckComboBox(final ObservableList<T> items) Creates a new CheckComboBox instance with the given items available as choices.
| |
| checkModelProperty | back to summary |
|---|---|
| public final ObjectProperty The check model provides the API through which it is possible to check single or multiple items within a CheckComboBox, as well as inspect which items have been checked by the user. Note that it has a generic type that must match the type of the CheckComboBox itself. | |
| converterProperty | back to summary |
|---|---|
| public final ObjectProperty A | |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. Create a new instance of the default skin for this control. This is called to create a skin for the control if
no skin is provided via CSS
| |
| getCheckModel | back to summary |
|---|---|
| public final IndexedCheckModel Returns the currently installed check model. | |
| getConverter | back to summary |
|---|---|
| public final StringConverter A | |
| getItemBooleanProperty | back to summary |
|---|---|
| public BooleanProperty getItemBooleanProperty(int index) Returns the | |
| getItemBooleanProperty | back to summary |
|---|---|
| public BooleanProperty getItemBooleanProperty(T item) Returns the | |
| getItems | back to summary |
|---|---|
| public ObservableList Represents the list of choices available to the user, from which they can select zero or more items. | |
| getTitle | back to summary |
|---|---|
| public final String getTitle() The title set for this control, if it has been set explicitly by the client.
| |
| hide | back to summary |
|---|---|
| public void hide() Closes the popup / dialog that was shown when | |
| isShowCheckedCount | back to summary |
|---|---|
public final boolean isShowCheckedCount()
| |
| setCheckModel | back to summary |
|---|---|
| public final void setCheckModel(IndexedCheckModel<T> value) Sets the 'check model' to be used in the CheckComboBox - this is the
code that is responsible for representing the selected state of each
| |
| setConverter | back to summary |
|---|---|
| public final void setConverter(StringConverter<T> value) Sets the
| |
| setShowCheckedCount | back to summary |
|---|---|
| public final void setShowCheckedCount(boolean value) Sets the value to use to decide whether the checked items count should be shown or not
| |
| setTitle | back to summary |
|---|---|
| public final void setTitle(String value) Sets the title to use. If it is not null it will be used as title, otherwise title will be constructed by the skin
| |
| show | back to summary |
|---|---|
| public void show() Requests that the ComboBox display the popup aspect of the user interface. | |
| showCheckedCountProperty | back to summary |
|---|---|
| public final BooleanProperty showCheckedCountProperty() A boolean to decide if the information of how many items are checked
should be shown beside the fixed title.
If a
| |
| titleProperty | back to summary |
|---|---|
| public final StringProperty titleProperty() The title to use for this control. If a non null value is explicitly set by the client, then that string will be used, otherwise a title will be constructed concatenating the selected items | |
| Modifier and Type | Field and Description |
|---|---|
| private final ObservableList | items
* Internal properties * * |
| Access | Constructor and Description |
|---|---|
| pack-priv | CheckComboBoxBitSetCheckModel(final ObservableList<T> items, final Map<T, BooleanProperty> itemBooleanMap)
* Constructors * * |
| Modifier and Type | Method and Description |
|---|---|
| public T | getItem(int index)
Implements abstract org. Implements org. * Implementing abstract API * * |
| public int | getItemCount()
Implements abstract org. Implements org. Returns the count of items in the control. |
| public int | getItemIndex(T item)
Implements abstract org. Implements org. Returns the index of the given item. |
| items | back to summary |
|---|---|
| private final ObservableList<T> items * Internal properties * * | |
| CheckComboBoxBitSetCheckModel | back to summary |
|---|---|
| pack-priv CheckComboBoxBitSetCheckModel(final ObservableList<T> items, final Map<T, BooleanProperty> itemBooleanMap) * Constructors * * | |
| getItem | back to summary |
|---|---|
| public T getItem(int index) Implements abstract org. Implements org. * Implementing abstract API * *
| |
| getItemCount | back to summary |
|---|---|
| public int getItemCount() Implements abstract org. Implements org. Doc from org. Returns the count of items in the control.
| |
| getItemIndex | back to summary |
|---|---|
| public int getItemIndex(T item) Implements abstract org. Implements org. Doc from org. Returns the index of the given item.
| |