ChangeListener for IntegerProperty : IntegerProperty « JavaFX « Java






ChangeListener for IntegerProperty

 
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;

public class Main {
  public static void main(String[] args) {
    IntegerProperty intProperty = new SimpleIntegerProperty(1024);
    final ChangeListener changeListener = new ChangeListener() {
      @Override
      public void changed(ObservableValue observableValue, Object oldValue,
          Object newValue) {
        System.out.println("oldValue:"+ oldValue + ", newValue = " + newValue);
      }
    };

    intProperty.addListener(changeListener);
    intProperty.set(5120);

    intProperty.removeListener(changeListener);

    intProperty.set(6144);
  }
}

   
  








Related examples in the same category

1.Binding IntegerProperty with multiply
2.Create IntegerProperty from SimpleIntegerProperty and set constant value
3.Get value from IntegerProperty with get method
4.Get int value from IntegerProperty
5.InvalidationListener for IntegerProperty
6.Bind and unbind IntegerProperty
7.Create JavaFX bean with IntegerProperty, StringProperty and ObjectProperty
8.Change new value for IntegerProperty with set method