本文整理汇总了Java中javafx.scene.control.ComboBox.setEditable方法的典型用法代码示例。如果您正苦于以下问题:Java ComboBox.setEditable方法的具体用法?Java ComboBox.setEditable怎么用?Java ComboBox.setEditable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ComboBox
的用法示例。
在下文中一共展示了ComboBox.setEditable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: fontSizeSelection
import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
private Node fontSizeSelection( EditorSettingDetails settingDetails )
{
HBox hBox = new HBox();
Text fontSizeLabel = new Text("Font Size: ");
fontSizeLabel.setId(UIConstants.TEXT_COLOR);
List<String> fontSizes = Arrays.asList("6", "8", "12", "14", "16", "20", "32", "48", "60", "72");
ObservableList<String> fontSizeList = FXCollections.observableArrayList(fontSizes);
ComboBox<String> fontSizesComboBox = new ComboBox<>(fontSizeList);
fontSizesComboBox.setEditable(true);
fontSizesComboBox.editorProperty().getValue().textProperty().addListener(( observable, oldValue, newValue )
-> {
if ( !newValue.isEmpty() )
UIStyle.applyError(VerifyUtil.simpleIntegerCheck(newValue), fontSizesComboBox);
});
fontSizesComboBox.getSelectionModel().select(settingDetails.getFontSize());
fontSizesComboBox.autosize();
fontSizeSelectionModel = fontSizesComboBox.getSelectionModel();
hBox.getChildren().addAll(fontSizeLabel, fontSizesComboBox);
hBox.setAlignment(Pos.CENTER_LEFT);
return hBox;
}