-1

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();

in the constructor

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

In the fxml file

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

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.

1 Answers1

3

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}">
James_D
  • 201,275
  • 16
  • 291
  • 322