本文整理汇总了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));
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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));
}
}
}
示例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);
}
示例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);
}
});
}
示例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);
}
示例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);
}