当前位置: 首页>>代码示例>>Java>>正文


Java ComboBox.setItems方法代码示例

本文整理汇总了Java中javafx.scene.control.ComboBox.setItems方法的典型用法代码示例。如果您正苦于以下问题:Java ComboBox.setItems方法的具体用法?Java ComboBox.setItems怎么用?Java ComboBox.setItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.ComboBox的用法示例。


在下文中一共展示了ComboBox.setItems方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ComboBoxSample

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
public ComboBoxSample() {

        HBox hbox = HBoxBuilder.create().alignment(Pos.CENTER).spacing(15).build();
               
        //Non-editable combobox. Created with a builder
        ComboBox uneditableComboBox = ComboBoxBuilder.create()
                .id("uneditable-combobox")
                .promptText("Make a choice...")
                .items(FXCollections.observableArrayList(strings.subList(0, 8))).build();

        //Editable combobox. Use the default item display length
        ComboBox<String> editableComboBox = new ComboBox<String>();
        editableComboBox.setId("second-editable");
        editableComboBox.setPromptText("Edit or Choose...");
        editableComboBox.setItems(strings);
        editableComboBox.setEditable(true);

        hbox.getChildren().addAll(uneditableComboBox, editableComboBox);
        getChildren().add(hbox);
    }
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:ComboBoxSample.java

示例2: start

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
    ComboBox<String> cmb = new JFXComboBox<>();
    new FilteredComboBoxDecorator<>(cmb, FilteredComboBoxDecorator.STARTSWITH_IGNORE_SPACES);
    cmb.setItems(FXCollections.observableArrayList(LISTA));
    Initializer.getToolBox()
            .getServices()
            .getConceptService()
            .findAllNames()
            .thenAccept(names -> {
               Platform.runLater(() -> cmb.setItems(FXCollections.observableArrayList(names)));
            });
    Scene scene = new Scene(new StackPane(cmb));
    scene.getStylesheets().addAll(Initializer.getToolBox().getStylesheets());
    stage.setScene(scene);
    stage.show();
    stage.setTitle("Filtered ComboBox");
    stage.setWidth(300);
    stage.setHeight(300);
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:21,代码来源:FilteredComboBoxDecoratorDemo.java

示例3: set

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
@Override
public void set(AttrEnum attrEnum, Object value)
{
    if (attrEnum == AttrEnum.ATTR_OTHER)
    {
        if (value instanceof ObservableList)
        {
            ObservableList observableList = (ObservableList) value;
            ComboBox comboBox = (ComboBox) view;
            comboBox.setItems(observableList);
        }
    } else
    {
        super.set(attrEnum, value);
    }
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:17,代码来源:ComboBoxBinder.java

示例4: createAndShowTableWindow

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
private void createAndShowTableWindow(ComboBox<String> traceNameComboBox) {
	openedWindowsCtr++;
	List<String> traceNames = new ArrayList<>();
	for (int i = 0; i < plotData.getAllTraces().size(); i++) {
		traceNames.add(plotData.getAllTraces().get(i).getTraceName());
	}
	traceNameComboBox.setItems(FXCollections.observableList(traceNames));
	traceNameComboBox.getSelectionModel().select(0);

	HBox hbox = new HBox();

	traceNameComboBox.getSelectionModel().select(0);
	Region spacer = new Region();
	HBox.setHgrow(spacer, Priority.ALWAYS);
	hbox.getChildren().addAll(new Label("Please Select a trace :"), spacer, traceNameComboBox);

	updateTableValues(traceNameComboBox);

	Scene scene = new Scene(new Group());
	VBox vbox = new VBox();
	VBox.setVgrow(table, Priority.ALWAYS);
	vbox.setSpacing(5);
	vbox.setPadding(new Insets(10, 10, 10, 10));
	vbox.prefWidthProperty().bind(scene.widthProperty());
	vbox.prefHeightProperty().bind(scene.heightProperty());
	vbox.getChildren().addAll(hbox, table);

	((Group) scene.getRoot()).getChildren().addAll(vbox);

	Stage stage = new Stage();
	stage.setOnCloseRequest(e -> closeTableWindow());
	stage.setWidth(300);
	stage.setHeight(400);
	stage.setScene(scene);
	stage.sizeToScene();
	stage.showAndWait();
}
 
开发者ID:jasrodis,项目名称:javafx-dataviewer,代码行数:38,代码来源:TopMenu.java

示例5: 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

示例6: populateComboBoxWithLanguages

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
private static void populateComboBoxWithLanguages(ComboBox<LanguageList> listLanguages) {
    final ObservableList<LanguageList> langList = FXCollections.observableArrayList();
    final LanguageList[] valuesLang = LanguageList.values();
    for (int i = 0; i < valuesLang.length; i++) {
        langList.add(valuesLang[i]);
    }
    listLanguages.setItems(langList);
}
 
开发者ID:Evegen55,项目名称:main_carauto_board,代码行数:9,代码来源:ApplicationSettingsController.java

示例7: populateComboBoxWithStyles

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
private static void populateComboBoxWithStyles(ComboBox<StyleList> listStylesBox) {
    //prior Java8 - simple and fast for small amount of data
    final ObservableList<StyleList> stylesList = FXCollections.observableArrayList();
    final StyleList[] values = StyleList.values();
    for (int i = 0; i < values.length; i++) {
        stylesList.add(values[i]);
    }

    //Java8 - hard to write but can be fast for big amount of data
    final ObservableList<String> styleLists = Arrays.stream(StyleList.values())
            .map(Enum::toString)
            .collect(collectingAndThen(toList(), FXCollections::observableArrayList));

    listStylesBox.setItems(stylesList);
}
 
开发者ID:Evegen55,项目名称:main_carauto_board,代码行数:16,代码来源:ApplicationSettingsController.java

示例8: TimeRangeFieldSkin

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
public TimeRangeFieldSkin(TimeRangeField control) {
    super(control);

    ComboBox<TimeRangeField.TimeRangeFieldValue> valuesComboBox = new ComboBox<>();
    valuesComboBox.setConverter(new TimeRangeFieldValueStringConverter());
    valuesComboBox.setItems(control.getValues());
    valuesComboBox.valueProperty().bindBidirectional(control.valueProperty());
    valuesComboBox.setVisibleRowCount(5);

    datePicker = new DatePicker();
    datePicker.getEditor().setPrefColumnCount(6);
    datePicker.valueProperty().bindBidirectional(control.onDateProperty());
    datePicker.managedProperty().bind(datePicker.visibleProperty());
    datePicker.setEditable(false);

    weekValueFactory = new IntegerSpinnerValueFactory(1, 52);
    weekValueFactory.valueProperty().addListener(obs -> control.setOnWeekNumber(weekValueFactory.getValue()));
    control.onWeekNumberProperty().addListener(obs -> {
        if (control.getOnWeekNumber() != null) {
            weekValueFactory.setValue(control.getOnWeekNumber());
        }
    });
    weekNumberSpinner = new Spinner<>();
    weekNumberSpinner.setValueFactory(weekValueFactory);
    weekNumberSpinner.managedProperty().bind(weekNumberSpinner.visibleProperty());
    weekNumberSpinner.setPrefWidth(70);

    monthYearValueFactory = new IntegerSpinnerValueFactory(1972, 3000);
    monthYearValueFactory.valueProperty().addListener(obs -> control.setMonthYear(monthYearValueFactory.getValue()));
    control.monthYearProperty().addListener(obs -> {
        if (control.getMonthYear() != null) {
            monthYearValueFactory.setValue(control.getMonthYear());
        }
    });

    monthYearSpinner = new Spinner<>();
    monthYearSpinner.getEditor().setPrefColumnCount(6);
    monthYearSpinner.setValueFactory(monthYearValueFactory);
    monthYearSpinner.managedProperty().bind(monthYearSpinner.visibleProperty());

    afterUnitsValueFactory = new IntegerSpinnerValueFactory(1, 500);
    afterUnitsValueFactory.valueProperty().addListener(obs -> control.setAfterUnits(afterUnitsValueFactory.getValue()));
    control.afterUnitsProperty().addListener(obs -> {
        if (control.getAfterUnits() != null) {
            afterUnitsValueFactory.setValue(control.getAfterUnits());
        }
    });
    afterUnitsSpinner = new Spinner<>();
    afterUnitsSpinner.getEditor().setPrefColumnCount(4);
    afterUnitsSpinner.setValueFactory(afterUnitsValueFactory);
    afterUnitsSpinner.managedProperty().bind(afterUnitsSpinner.visibleProperty());
    afterUnitsLabel = new Label();
    afterUnitsLabel.managedProperty().bind(afterUnitsLabel.visibleProperty());

    InvalidationListener listener = obs -> layout();
    control.viewTypeProperty().addListener(listener);
    control.valueProperty().addListener(listener);

    HBox container = new HBox(5, valuesComboBox, datePicker, weekNumberSpinner, monthYearSpinner, afterUnitsSpinner, afterUnitsLabel);
    container.setAlignment(Pos.CENTER_LEFT);
    HBox.setHgrow(valuesComboBox, Priority.ALWAYS);
    HBox.setHgrow(datePicker, Priority.SOMETIMES);

    getChildren().add(container);
    layout();
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:67,代码来源:TimeRangeFieldSkin.java

示例9: HierarchicalConceptComboBoxDecorator

import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
public HierarchicalConceptComboBoxDecorator(ComboBox<String> comboBox, ConceptService conceptService) {
    this.comboBox = comboBox;
    this.conceptService = conceptService;
    comboBox.setItems(FXCollections.observableArrayList());
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:6,代码来源:HierarchicalConceptComboBoxDecorator.java


注:本文中的javafx.scene.control.ComboBox.setItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。