我想从totalAmount
IntegerBind
TextField
和值{}
我知道这种语法无效,因为它们与解析TextField
和IntegerBind
标识符不兼容。
int parseReceivedCash = Integer.parseInt(receivedCashTextField.getText());
if((parseReceivedCash - alltotal))
{
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setHeaderText("Not Enough Cas");
alert.setContentText("Sorry not enough cash" );
alert.showAndWait();
}
alltotal = Bindings.createIntegerBinding(() ->
tableData.getItems().stream().collect(Collectors.summingInt(Data::getSubTotal)),
tableData.getItems());
答案 0 :(得分:0)
有些事情:
IntegerProperty receivedCash = new SimpleIntegerProperty();
receivedCashTextField.textProperty().bindBidirectional(receivedCash, new NumberStringConverter());
IntegerBinding remainingAmount = allTotal.subtract(receivedCash);
remainingAmount.addListener(...); // check if amount is enough, etc...
应该提供您正在寻找的功能