将IntegerProperty [value:]更改为正义值

我约束工厂剩余物品的数量。

private int item;
private SimpleIntegerProperty itemProperty = new SimpleIntegerProperty();
private SimpleIntegerProperty remainingItem = new Simple IntegerProperty();
private SimpleIntegerProperty soldItem = new Simple IntegerProperty();

在构造函数中

this.item = item;
itemProperty.set(item);
soldItem.set(0);
remainingItem.bind(soldItem.subtract(item).multiply(-1));
//itemProperty.bind((soldItem.subtract(item).multiply(-1));

在fxml文件中

<Text text="${controller.factory.remainingProperty.get()}">

当我尝试绑定itemProperty时,它给出无效的 当我尝试使用get方法显示剩余属性ReadOnlyIntegerProperty时,它将在主类中抛出 EXCEPTION

我正在尝试从 商品 中减去商品数 并显示它。

iCMS 回答:将IntegerProperty [value:]更改为正义值

Expression bindings不是方法调用;他们有不同的语法。在这里,假设控制器中有适当的*属性,并且定义了适当的方法(factory),则应使用

remainingItemProperty()
本文链接:https://www.f2er.com/2291878.html

大家都在问