Listener in JavaFX

2

Good evening, I have run into a small problem when writing the code of an interface. The part of the code that fails is:

final BooleanBinding activarComprobacion = campo1.textProperty().isEqualsTo("");
activarComprobacion.addListener((ObservableValue<? extends Bolean> observable, Boolean oldValue, Boolean newValue) -> {
    System.out.println("Tendria que salir esto al seleccionar alguna opcion de campo1");
}

No compilation error or anything like that, in fact, before I used a button to check and everything was fine. Inside the lambda function I did several things, but I removed it because it was irrelevant.

    
asked by B4nshee 19.04.2017 в 23:28
source

1 answer

1

I have tested this solution with a TextField and it works by using a ChangeListener. Let me know if it solves your problem, Regards.

campo1.textProperty().addListener((observable, oldValue, newValue) -> {
        if(newValue.equals("")){
            System.out.println("Tendria que salir esto al seleccionar alguna opcion de campo1");
        }
    });
    
answered by 12.05.2017 в 16:06