我不知道为什么,但是只要单击按钮,我就试图绑定SimpleInteger。
我尝试了这个。
private int item;
private SimpleIntegerProperty itemsold = new SimpleIntegerProperty();
private SimpleIntegerProperty itemProperty = new SimpleIntegerProperty();
//Constructor
this.item = item;
itemSold.set(0);
itemProperty.bind(itemSold.subtract(item).multiply(-1));
而且我可以在FXML文件中使用itemProperty进行显示。 因此,我必须在itemProperty上获取方法。
public final int getItemProperty(){ return itemProperty.get()}
public void sell(int amount){ itemSold.set(itemSold.get() + amount);}
<Text text="${controller.factory.item.getItemProperty}"/>
尝试加载项目时。 单击该按钮,然后将指导卖方方法。 我不确定为什么它不能正常工作。
数小时使我发疯。 如果您需要更多信息,我将对其进行编辑。 有人可以帮忙吗?
非常感谢您抽出宝贵的时间。