Java Code Examples for javafx.scene.control.SingleSelectionModel#getSelectedItem()

The following examples show how to use javafx.scene.control.SingleSelectionModel#getSelectedItem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateTerrainDialog.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Update a list of available path sizes.
 */
@FxThread
private void updatePathSizeValues() {

    final ComboBox<Integer> pathSizeComboBox = getPatchSizeComboBox();
    final SingleSelectionModel<Integer> selectionModel = pathSizeComboBox.getSelectionModel();
    final Integer current = selectionModel.getSelectedItem();

    final ObservableList<Integer> items = pathSizeComboBox.getItems();
    items.clear();

    final ComboBox<Integer> totalSizeComboBox = getTotalSizeComboBox();
    final Integer naxValue = totalSizeComboBox.getSelectionModel().getSelectedItem();

    for (final Integer value : PATCH_SIZE_VARIANTS) {
        if (value >= naxValue) break;
        items.add(value);
    }

    if (items.contains(current)) {
        selectionModel.select(current);
    } else {
        selectionModel.select(items.get(items.size() - 1));
    }
}
 
Example 2
Source File: RFXTabPane.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
protected void mouseClicked(MouseEvent me) {
    TabPane tp = (TabPane) node;
    SingleSelectionModel<Tab> selectionModel = tp.getSelectionModel();
    Tab selectedTab = selectionModel.getSelectedItem();
    if (selectedTab != null && prevSelection != selectionModel.getSelectedIndex()) {
        recorder.recordSelect(this, getTextForTab(tp, selectedTab));
    }
    prevSelection = selectionModel.getSelectedIndex();
}