本文整理匯總了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;
}