本文整理汇总了Java中javafx.scene.control.TableColumn.setOnEditCommit方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.setOnEditCommit方法的具体用法?Java TableColumn.setOnEditCommit怎么用?Java TableColumn.setOnEditCommit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TableColumn
的用法示例。
在下文中一共展示了TableColumn.setOnEditCommit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processChoiceBoxColumnName
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
private TableColumn processChoiceBoxColumnName(String name, JsonArray items){
TableColumn column = new TableColumn(name);
column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
ObservableList list = FXCollections.observableArrayList();
if(items!=null) list.addAll(items.getList());
column.setCellFactory(ChoiceBoxTableCell.forTableColumn(list));
column.setOnEditCommit( t -> {
int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
});
columnMap.put(name, column);
return column;
}
示例2: processComboBoxColumnName
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
private TableColumn processComboBoxColumnName(String name, JsonArray items){
TableColumn column = new TableColumn(name);
column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
ObservableList list = FXCollections.observableArrayList();
if(items!=null) list.addAll(items.getList());
column.setCellFactory(ComboBoxTableCell.forTableColumn(list));
column.setOnEditCommit( t -> {
int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
});
columnMap.put(name, column);
return column;
}
示例3: processStringColumnName
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
private TableColumn processStringColumnName(String name){
TableColumn column = new TableColumn(name);
column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
column.setCellFactory(TextFieldTableCell.forTableColumn());
column.setOnEditCommit( t -> {
int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
});
columnMap.put(name, column);
return column;
}
示例4: processCheckBoxColumnName
import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
private TableColumn processCheckBoxColumnName(String name){
TableColumn column = new TableColumn(name);
column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Boolean>)p).getValue().getBooleanProperty(name));
column.setCellFactory(CheckBoxTableCell.forTableColumn(column));
column.setOnEditCommit( t -> {
int index = ((TableColumn.CellEditEvent<Item, Boolean>) t).getTablePosition().getRow();
Item item = ((TableColumn.CellEditEvent<Item, Boolean>) t).getTableView().getItems().get(index);
item.setProperty(name,((TableColumn.CellEditEvent<Item, Boolean>) t).getNewValue());
});
columnMap.put(name, column);
return column;
}