當前位置: 首頁>>代碼示例>>Java>>正文


Java ComboBox.getItems方法代碼示例

本文整理匯總了Java中javafx.scene.control.ComboBox.getItems方法的典型用法代碼示例。如果您正苦於以下問題:Java ComboBox.getItems方法的具體用法?Java ComboBox.getItems怎麽用?Java ComboBox.getItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.control.ComboBox的用法示例。


在下文中一共展示了ComboBox.getItems方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updatePathSizeValues

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
/**
 * 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));
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:28,代碼來源:CreateTerrainDialog.java

示例2: reload

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
@Override
@FXThread
protected void reload() {
    if (!hasEditObject()) return;

    final Geometry geometry = getEditObject();
    final Mesh mesh = geometry.getMesh();
    if (mesh == null) return;

    final Integer element = getPropertyValue();
    final ComboBox<Integer> levelComboBox = getLevelComboBox();
    final ObservableList<Integer> items = levelComboBox.getItems();
    items.clear();

    final int numLodLevels = mesh.getNumLodLevels();

    for (int i = 0; i < numLodLevels; i++) {
        items.add(i);
    }

    if (items.isEmpty()) {
        items.add(0);
    }

    levelComboBox.getSelectionModel().select(element);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:LodLevelPropertyControl.java

示例3: reload

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
@Override
@FXThread
protected void reload() {

    final SceneChangeConsumer changeConsumer = (SceneChangeConsumer) getChangeConsumer();
    final SceneNode currentModel = changeConsumer.getCurrentModel();
    final SceneLayer sceneLayer = getPropertyValue();

    final ComboBox<SceneLayer> levelComboBox = getLayerComboBox();
    final ObservableList<SceneLayer> items = levelComboBox.getItems();
    items.clear();
    items.add(SceneLayer.NO_LAYER);
    items.addAll(currentModel.getLayers());

    levelComboBox.getSelectionModel().select(sceneLayer == null ? SceneLayer.NO_LAYER : sceneLayer);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:17,代碼來源:LayerModelPropertyControl.java

示例4: reload

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
/**
 * Reload the material.
 */
@FXThread
private void reload(@NotNull final Material material) {
    setCurrentMaterial(material);
    setIgnoreListeners(true);
    try {

        final MaterialEditor3DState editor3DState = getEditor3DState();
        editor3DState.updateMaterial(material);

        getSettingsTree().fill(new RootMaterialSettings(material));

        final ComboBox<String> materialDefinitionBox = getMaterialDefinitionBox();
        final ObservableList<String> items = materialDefinitionBox.getItems();
        items.clear();
        items.addAll(RESOURCE_MANAGER.getAvailableResources(FileExtensions.JME_MATERIAL_DEFINITION));

        final MaterialDef materialDef = material.getMaterialDef();
        materialDefinitionBox.getSelectionModel().select(materialDef.getAssetName());

    } finally {
        setIgnoreListeners(false);
    }
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:27,代碼來源:MaterialFileEditor.java

示例5: getComboBoxItemIndex

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
public int getComboBoxItemIndex(ComboBox<?> comboBox, String value) {
    ObservableList<?> items = comboBox.getItems();
    for (int i = 0; i < items.size(); i++) {
        String text = getComboBoxText(comboBox, i, true);
        if (text.equals(value)) {
            return i;
        }
    }
    return -1;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:JavaFXElementPropertyAccessor.java

示例6: selectCollectionToRun

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
public void selectCollectionToRun(String collectionName) throws TimeoutException {
    ComboBox<Collection> comboBox = lookup("#collections-combo-box").query();
    clickOn(comboBox);

    for (Collection collection : comboBox.getItems()) {
        if(collection.getName().equals(collectionName)) {
            interact(() -> comboBox.getSelectionModel().select(collection));
        }
    }
}
 
開發者ID:AntonioGabrielAndrade,項目名稱:LIRE-Lab,代碼行數:11,代碼來源:AppViewObject.java

示例7: AutoCompleteComboBoxListener

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
public AutoCompleteComboBoxListener(final ComboBox<T> comboBox, final Function<T, String> transform) {
    this.comboBox = comboBox;
    this.transform = transform;

    data = comboBox.getItems();
    comboBox.itemsProperty().addListener((obs, oldv, newv) -> {
        data = newv;
    });

    this.comboBox.setEditable(true);
    this.comboBox.setOnKeyPressed(e -> comboBox.hide());
    this.comboBox.setOnKeyReleased(AutoCompleteComboBoxListener.this);
}
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:14,代碼來源:AutoCompleteComboBoxListener.java

示例8: FilteredComboBoxDecorator

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
public FilteredComboBoxDecorator(final ComboBox<T> comboBox,
                                 AutoCompleteComparator<T> comparator) {
    this.comboBox = comboBox;
    this.comparator = comparator;

    filteredItems = new FilteredList<>(comboBox.getItems());
    comboBox.setItems(filteredItems);

    Tooltip tooltip = new Tooltip();
    tooltip.getStyleClass().add("tooltip-combobox");
    comboBox.setTooltip(tooltip);
    filter.addListener((observable, oldValue, newValue) -> handleFilterChanged(newValue));
    comboBox.setOnKeyPressed(this::handleOnKeyPressed);
    comboBox.setOnHidden(this::handleOnHiding);

    comboBox.itemsProperty().addListener((obs, oldV, newV) -> {
        if (newV != filteredItems) {
            //log.info("New list of size " + newV.size());
            if (!(newV instanceof FilteredList)) {
                filteredItems = new FilteredList<>(newV);
            }
            else {
                filteredItems = (FilteredList<T>) newV;
            }
            comboBox.setItems(filteredItems);
        }
    });
}
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:29,代碼來源:FilteredComboBoxDecorator.java

示例9: validate

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
@Override
@FXThread
protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) {

    final ComboBox<String> comboBox = getTextureParamNameComboBox();
    final ObservableList<String> items = comboBox.getItems();
    items.clear();

    final Path file = element == null ? null : element.getFile();

    if (file != null && !Files.isDirectory(file)) {

        final AssetManager assetManager = EDITOR.getAssetManager();
        final Path assetFile = getAssetFile(file);

        if (assetFile == null) {
            throw new RuntimeException("AssetFile can't be null.");
        }

        final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile));
        final Material material = assetManager.loadAsset(materialKey);
        final MaterialDef materialDef = material.getMaterialDef();

        final Collection<MatParam> materialParams = materialDef.getMaterialParams();
        materialParams.stream()
                .filter(param -> param.getVarType() == VarType.Texture2D)
                .filter(matParam -> material.getTextureParam(matParam.getName()) != null)
                .forEach(filtred -> items.add(filtred.getName()));

        final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel();

        if (!items.isEmpty()) {
            selectionModel.select(0);
        } else {
            selectionModel.select(null);
        }
    }

    super.validate(warningLabel, element);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:41,代碼來源:ParticlesAssetEditorDialog.java

示例10: addSpecialInstrumentationItem

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
public static void addSpecialInstrumentationItem(int id, KeyValuePair sectionType, KeyValuePair specialInstrumentation, int specialInstrumentationCount,
                                                 List<SpecialInstrumentationEntity> specialInstrumentationEntityList, GridPane specialInstrumentationContent,
                                                 ComboBox<KeyValuePair> specialInstrumentationSectionGroupComboBox, NumberField specialInstrumentationNumberField) {
    GridPane tmpPane = new GridPane();

    ComboBox<KeyValuePair> sectionTypeComboBox = new ComboBox<>(specialInstrumentationSectionGroupComboBox.getItems());
    sectionTypeComboBox.getSelectionModel().select(sectionType);
    sectionTypeComboBox.setMaxWidth(100);
    sectionTypeComboBox.setMinWidth(100);
    tmpPane.addColumn(0, sectionTypeComboBox);

    ComboBox<KeyValuePair> specialInstrumentationComboBox = new ComboBox<>(TeamF.client.helper.gui.InstrumentationHelper.getInstrumentTypes((SectionGroupType) sectionTypeComboBox.getSelectionModel().getSelectedItem().getValue()));
    specialInstrumentationComboBox.getSelectionModel().selectFirst();
    specialInstrumentationComboBox.setMaxWidth(100);
    specialInstrumentationComboBox.setMinWidth(100);
    tmpPane.addColumn(1, specialInstrumentationComboBox);

    NumberField tmpNumberField = null;
    try {
        tmpNumberField = new NumberField(specialInstrumentationCount, specialInstrumentationNumberField.getMinValue().intValue(), specialInstrumentationNumberField.getMaxValue().intValue());
        tmpPane.addColumn(2, tmpNumberField);
        tmpNumberField.setMaxWidth(60);
        tmpNumberField.setStyle("-fx-opacity: 1");
    } catch (NumberRangeException e) {
    }

    sectionTypeComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            if(((TeamF.client.helper.gui.InstrumentationHelper.getInstrumentTypes((SectionGroupType) sectionTypeComboBox.getSelectionModel().
                    getSelectedItem().getValue())))!=null) {
                specialInstrumentationComboBox.setItems((TeamF.client.helper.gui.InstrumentationHelper.getInstrumentTypes((SectionGroupType) sectionTypeComboBox.getSelectionModel().
                        getSelectedItem().getValue())));
                specialInstrumentationComboBox.getSelectionModel().selectFirst();
            }
        }
    });

    Button tmpButton = new Button("-");
    tmpPane.addColumn(3, tmpButton);

    specialInstrumentationContent.addRow(specialInstrumentationEntityList.size()+1, tmpPane);
    specialInstrumentationContent.setColumnSpan(tmpPane, 4);
    SpecialInstrumentationEntity specialInstrumentationEntity = new SpecialInstrumentationEntity(id, sectionTypeComboBox, specialInstrumentationComboBox, tmpNumberField, tmpPane);

    tmpButton.setOnAction(e -> removeSpecialInstrumentationItem(specialInstrumentationEntity, specialInstrumentationContent, specialInstrumentationEntityList));

    specialInstrumentationEntityList.add(specialInstrumentationEntity);
}
 
開發者ID:ITB15-S4-GroupD,項目名稱:Planchester,代碼行數:49,代碼來源:InstrumentationHelper.java


注:本文中的javafx.scene.control.ComboBox.getItems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。