How implement javafx label value change listener


Question

how call the listener when Label text changed

 Label myLabel= new Label("text1");

if i change the text

myLabel.settext("text2");

There is any listener so that i can perform this

myLabel.LISTENER{
System.out.println("Label Text Changed");
}
1
1
3/30/2014 5:24:34 AM

well i found the answer after some rnd here is code

myLabel.textProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> ov, String t, String t1) {
               System.out.println("Label Text Changed");
            }
        }); 
6
3/30/2014 5:31:09 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon