将IntegerProperty [value:]更改为正义值 [英] Changing IntegerProperty[value: ] to just value

查看:96
本文介绍了将IntegerProperty [value:]更改为正义值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am bind the value of number of items left in the factory.

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 .

when I try to bind itemProperty it give invalid when I try to display with remainingProperty ReadOnlyIntegerProperty with get method,it throws EXCEPTION in the main class.

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

I am trying to subtract the number of item from item and display it.

推荐答案

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

Expression bindings are not method calls; they have a different syntax. Here, assuming there is an appropriate factory property in the controller with the appropriate method defined (remainingItemProperty()), you should use

<Text text="${controller.factory.remainingItem}">

这篇关于将IntegerProperty [value:]更改为正义值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆