계산서에있는 모든 제품을 나열하고자하는 bill table이 있습니다. 청구서의 ArrayList<ProductInBill>
내에 ProductInBill
개의 개체를 저장했습니다.JavaFX : 계산 된 정수 값을 TableColumn에 추가하는 방법
TableView
을 만들 때 일반적인 접근 방법은 JavaFX 필드를 만드는 것입니다. 그리고 내가 좋아하는 코드와 setUp()
방법을 사용하고
@FXML public TableColumn<ProductInBill, String> finishedBillProductNameColumn;
@FXML public TableColumn<Integer, Integer> finishedBillProductNumberColumn;
@FXML public TableColumn<ProductInBill, Integer> finishedBillProductPriceBruttoLabel;
@FXML public TableColumn<Integer, Integer> finishedBillProductTotalAmountColumn;
@FXML public TableView finishedBillProductTable;
: 컨트롤러 클래스에, 나는 내 분야가
private void setUpFinishedBillProductTable() {
finishedBillProductNameColumn.setCellValueFactory(new PropertyValueFactory<ProductInBill, String>("productName"));
finishedBillProductPriceBruttoLabel.setCellValueFactory(new PropertyValueFactory<ProductInBill, Integer>("productPrice"));
}
이 또한 필요한 ProductInBill
객체를로드 할 updateBillTable()
방법이를 저장 그들을 TableList에 추가하고 그것을 테이블에 준다.
private void updateFinishedBillProductTable(Bill bill) {
LOG.info("Start reading all Products from Bill");
for(ProductInBill product : bill.getProducts()){
finishedBillProductCurrent.add(product);
}
finishedBillProductTable.getItems().clear();
if(!finishedBillProductCurrent.isEmpty()) {
for (ProductInBill p : finishedBillProductCurrent) {
finishedBillProductTableList.add(p);
}
//here i want to calculate some other Integer values based on the ProductInBill values and insert them to the table too.
finishedBillProductTable.setItems(finishedBillProductTableList);
}
}
이것은 모두 매우 효과적입니다. 내 문제는 지금, 내가 내 TableView
필드에 개체 내에서 저장하지 않으려는 계산 된 정수 값이 있다는 것입니다.
예를 들어 finishedBillProductNumberColumn
을들 수 있습니다. 내 ArrayList
에서 반복을 원하고 같은 이름을 가진 모든 제품을 찾아 테이블에 같은 항목의 번호를 채 웁니다.
어떻게하면됩니까? 내 TableView
에 무언가를 삽입하기 위해 객체의 값을 사용해야하는 유일한 해결책을 발견했습니다.