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