【发布时间】:2020-02-02 02:57:04
【问题描述】:
The Java Swing run imageThe JavaFx run image我需要将整个 ComboBox 添加到 TableView 列,而不是 JavaFx 中的 OservableArrayList,因为我像 java swing 一样为 ComboBox 设置了自动完成属性,所以我使用 java swing 进行了尝试,它工作成功,但没有t在javafx中工作
@Override
public void start(Stage primaryStage) {
StackPane root = new StackPane();
Scene scene = new Scene(root, 300, 250);
TableView table = new TableView();
ObservableList <String> list = FXCollections.observableArrayList();
ComboBox comboBox = new ComboBox();
list.add("Product One");
list.add("Product Two");
list.add("Product Three");
list.add("Product Four");
table.setEditable(true);
comboBox.setEditable(true);
comboBox.setItems(list);
TextFields.bindAutoCompletion(comboBox.getEditor(), comboBox.getItems());
TableColumn productName = new TableColumn("Product Name");
TableColumn productCode = new TableColumn("Product Code");
productName.setEditable(true);
productName.setCellValueFactory(ComboBoxTableCell.forTableColumn(list));
productName.setMinWidth(100);
productCode.setMinWidth(100);
table.getColumns().addAll(productName, productCode);
table.getItems().add(new Object [] {null, null});
root.getChildren().add(table);
primaryStage.setTitle("Test");
primaryStage.setScene(scene);
primaryStage.show();
}
【问题讨论】:
-
为什么要在不同的标签下重新发布完全相同的问题(而不是编辑the old)?您唯一的改变是使用正确的参数...
-
好的,谢谢,我忘了删除旧的
标签: java combobox tableview javafx-8 editor