0
tablecolumnの各テーブルセルの値が変数に取得されません。 テーブルビューの各セルの値を取得するにはどうすればよいですか?javafxでtablecolumnの各セルの値を取得して変数に格納する方法
このコードを使用してセル値を取得しようとしましたが、動作していないため、エラーが発生しています。
int mappingid = Integer.parseInt(ocolFileOutputMappingId.getText());
int srno = Integer.parseInt(ocolFileSrno.getText());
String filedname = ocolFieldName.getText();
私の完全なコードは次のとおりです。
@FXML
private TableColumn<InputMappingFieldModel, Integer> ocolFileSrno;// for srno
@FXML
private TableColumn<InputMappingFieldModel, Integer> ocolFileOutputMappingId;//thisfor output mapping id
@FXML
private TableColumn<InputMappingFieldModel, String> ocolFieldName;
upaction.setOnAction(evt -> {
int index = otableview.getSelectionModel().getSelectedInde);
// swap items
otableview.getItems().add(index - 1, otableview.getItems().remove(index));
// select item at new position
otableview.getSelectionModel().clearAndSelect(index - 1);
// code to insert shuffle data in table
try {
int txtmapoutputid = Integer.parseInt(outputIdText.getText());
String sql = "update OUTPUT_MAPPING set SERIAL_NUMBER=?,FIELD_NAME=?,OUTPUT_MAPPING_ID=? where OUTPUT_ID="+txtmapoutputid;
// System.out.println("SQL IS mapping Update "+txtmapinputid);
PreparedStatement psmt = conn.prepareStatement(sql);
int mappingid = Integer.parseInt(ocolFileOutputMappingId.getText());
int srno = Integer.parseInt(ocolFileSrno.getText());
String filedname = ocolFieldName.getText();
psmt.setInt(1, srno);
psmt.setString(2, filedname);
psmt.setInt(3, mappingid);
psmt.executeUpdate();
} catch (Exception ex) {
ex.printStackTrace();
}
otableview.getColumns().setAll(ocolFileSrno, ocolFieldName, col_spaceswap, ocolFileOutputMappingId);//remove actionColUpdate from parameter list
otableview.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
otableview.setItems(modelViewField);
otableview.refresh();
});
は、誰もが親切に私のテーブルビューでテーブルの列のセルの値を取得する方法のためのロジックを提供することができますか?
はあなただけ表示される行の値を好きな理由はありますか? – fabian