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


Java ComboBox類代碼示例

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


ComboBox類屬於javafx.scene.control包,在下文中一共展示了ComboBox類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

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

示例4: WeekFieldsViewSkin

import javafx.scene.control.ComboBox; //導入依賴的package包/類
public WeekFieldsViewSkin(final WeekFieldsView view) {
    super(view);

    dayOfWeekComboBox = new ComboBox<>();
    dayOfWeekComboBox.getItems().addAll(DayOfWeek.values());
    dayOfWeekComboBox.setValue(view.getFirstDayOfWeek());

    minimalDaysInFirstWeekComboBox = new ComboBox<>();
    minimalDaysInFirstWeekComboBox.getItems().addAll(1, 2, 3, 4, 5, 6, 7);
    minimalDaysInFirstWeekComboBox.setValue(view.getMinimalDaysInFirstWeek());

    GridPane pane = new GridPane();
    pane.getStyleClass().add("content");
    pane.add(new Label("First day:"), 0, 0);
    pane.add(new Label("Minimum days:"), 0, 1);
    pane.add(dayOfWeekComboBox, 1, 0);
    pane.add(minimalDaysInFirstWeekComboBox, 1, 1);

    getChildren().add(pane);

    // listeners

    InvalidationListener updateListener = it -> updateValues();
    dayOfWeekComboBox.valueProperty().addListener(updateListener);
    minimalDaysInFirstWeekComboBox.valueProperty().addListener(updateListener);

    view.weekFieldsProperty().addListener(it -> {
        WeekFields fields = view.getWeekFields();
        dayOfWeekComboBox.setValue(fields.getFirstDayOfWeek());
        minimalDaysInFirstWeekComboBox.setValue(fields.getMinimalDaysInFirstWeek());
    });
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:33,代碼來源:WeekFieldsViewSkin.java

示例5: setFormConstraints

import javafx.scene.control.ComboBox; //導入依賴的package包/類
private void setFormConstraints(Node field) {
    if (field instanceof ISetConstraints) {
        ((ISetConstraints) field).setFormConstraints(this);
    } else if (field instanceof Button) {
        _setFormConstraints((Button) field);
    } else if (field instanceof TextField) {
        _setFormConstraints((TextField) field);
    } else if (field instanceof TextArea) {
        _setFormConstraints((TextArea) field);
    } else if (field instanceof ComboBox<?>) {
        _setFormConstraints((ComboBox<?>) field);
    } else if (field instanceof ChoiceBox<?>) {
        _setFormConstraints((ChoiceBox<?>) field);
    } else if (field instanceof CheckBox) {
        _setFormConstraints((CheckBox) field);
    } else if (field instanceof Spinner<?>) {
        _setFormConstraints((Spinner<?>) field);
    } else if (field instanceof VBox) {
        _setFormConstraints((VBox) field);
    } else if (field instanceof Label) {
        _setFormConstraints((Label) field);
    } else {
        LOGGER.info("FormPane.setFormConstraints(): unknown field type: " + field.getClass().getName());
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:26,代碼來源:FormPane.java

示例6: getComboBoxText

import javafx.scene.control.ComboBox; //導入依賴的package包/類
public String getComboBoxText(ComboBox<?> comboBox, int index, boolean appendText) {
    if (index == -1) {
        return null;
    }
    String original = getComboBoxItemText(comboBox, index);
    String itemText = original;
    int suffixIndex = 0;
    for (int i = 0; i < index; i++) {
        String current = getComboBoxItemText(comboBox, i);
        if (current.equals(original)) {
            if (appendText) {
                itemText = String.format("%s(%d)", original, ++suffixIndex);
            } else {
                itemText = original;
            }
        }
    }
    return itemText;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:20,代碼來源:JavaFXElementPropertyAccessor.java

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

示例8: createComponents

import javafx.scene.control.ComboBox; //導入依賴的package包/類
@Override
@FXThread
protected void createComponents(@NotNull final HBox container) {
    super.createComponents(container);

    layerComboBox = new ComboBox<>();
    layerComboBox.setCellFactory(param -> new LayerCell());
    layerComboBox.setButtonCell(new LayerCell());
    layerComboBox.setEditable(false);
    layerComboBox.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));
    layerComboBox.getSelectionModel().selectedItemProperty()
            .addListener((observable, oldValue, newValue) -> updateLevel(newValue));

    FXUtils.addToPane(layerComboBox, container);
    FXUtils.addClassTo(layerComboBox, CSSClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:17,代碼來源:LayerModelPropertyControl.java

示例9: comboBoxValueChanged

import javafx.scene.control.ComboBox; //導入依賴的package包/類
@FXML
public void comboBoxValueChanged(Event evt) {
    ComboBox actionBox = ((ComboBox) evt.getSource());

    switch (actionBox.getId()) {
        case "action1":
            region1.setDisable(!actionBox.getValue().equals("Delegation"));
            break;
        case "action2":
            region2.setDisable(!actionBox.getValue().equals("Delegation"));
            break;
        case "action3":
            region3.setDisable(!actionBox.getValue().equals("Delegation"));
            break;
        case "action4":
            region4.setDisable(!actionBox.getValue().equals("Delegation"));
            break;
        case "action5":
            region5.setDisable(!actionBox.getValue().equals("Delegation"));
            break;
        case "action6":
            region6.setDisable(!actionBox.getValue().equals("Delegation"));
            break;
    }
}
 
開發者ID:sebastienscout,項目名稱:Himalaya-JavaFX,代碼行數:26,代碼來源:ActionsFXMLController.java

示例10: focusLost

import javafx.scene.control.ComboBox; //導入依賴的package包/類
@Override public void focusLost(RFXComponent next) {
    ComboBox<?> comboBox = (ComboBox<?>) node;
    Object selectedItem = comboBox.getSelectionModel().getSelectedItem();
    if (comboBox.isEditable() && comboBox.getEditor().getText()
            .equals(getComboBoxText(comboBox, comboBox.getItems().indexOf(prevSelectedItem), false))) {
        return;
    } else if (!comboBox.isEditable() && selectedItem != null && selectedItem.equals(prevSelectedItem)) {
        return;
    }
    if (!comboBox.isEditable()) {
        recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true));
    } else {
        String editorText = comboBox.getEditor().getText();
        String selectedItemText = getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), false);
        if (editorText.equals(selectedItemText)) {
            recorder.recordSelect(this, getComboBoxText(comboBox, comboBox.getSelectionModel().getSelectedIndex(), true));
        } else {
            recorder.recordSelect(this, editorText);
        }
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:22,代碼來源:RFXComboBox.java

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

示例12: createCombo

import javafx.scene.control.ComboBox; //導入依賴的package包/類
private ComboBox<ILevel> createCombo (ObservableList<ILevel> levels) {
    ComboBox<ILevel> comboBox = new ComboBox<>(levels);
    comboBox.setCellFactory(c -> new NameCellView<>());
    comboBox.setButtonCell(new NameCellView<>());
    myCombos.add(comboBox);
    return comboBox;
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:8,代碼來源:TransitionView.java

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

示例14: start

import javafx.scene.control.ComboBox; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
	GridPane pane = new GridPane();
	pane.setAlignment(Pos.CENTER);
	pane.setMaxSize(800, 600);
	pane.setPrefSize(800, 600);
	pane.setManaged(true);
	pane.setVgap(3);
	pane.setHgap(3);
	pane.addRow(1, new Label("Chess Master"));
	ComboBox<RenderWrapper> renderCombo = new ComboBox<>();
	renderCombo.getItems().addAll(new RenderWrapper(new BGFXRenderer()), new RenderWrapper(new OpenGLRenderer()));
	ChessMaster.getPluginManager().getExtensions(Renderer.class).stream().map(RenderWrapper::new).forEach(renderCombo.getItems()::add);
	pane.addRow(2, new Label("Select a renderer:"), renderCombo);
	Button button = new Button("Start!");
	button.setOnAction(event -> {
		ChessMaster.getLogger().info("Using renderer: {} ({})", renderCombo.getSelectionModel().getSelectedItem().renderer.getName(), renderCombo.getSelectionModel().getSelectedItem().renderer.getClass().getName());
		renderCombo.getSelectionModel().getSelectedItem().renderer.render();
		primaryStage.close();
	});
	pane.addRow(3, button);
	primaryStage.setScene(new Scene(pane));
	primaryStage.show();
}
 
開發者ID:HuajiStudio,項目名稱:ChessMaster,代碼行數:25,代碼來源:RenderEngineSelector.java

示例15: processOpen

import javafx.scene.control.ComboBox; //導入依賴的package包/類
@Override
@FXThread
protected void processOpen(@NotNull final ResourceElement element) {
    super.processOpen(element);

    final ComboBox<String> textureParamNameBox = getTextureParamNameComboBox();
    final SingleSelectionModel<String> selectionModel = textureParamNameBox.getSelectionModel();
    final String textureParamName = selectionModel.getSelectedItem();

    final CheckBox transformBox = getApplyLightingTransformCheckBox();

    final AssetManager assetManager = EDITOR.getAssetManager();

    final Path file = element.getFile();
    final Path assetFile = getAssetFile(file);

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

    final Material material = assetManager.loadAsset(new MaterialKey(toAssetPath(assetFile)));

    final Consumer<ParticlesMaterial> consumer = getConsumer();
    consumer.accept(new ParticlesMaterial(material, textureParamName, transformBox.isSelected()));
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:26,代碼來源:ParticlesAssetEditorDialog.java


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