如何实现javafx标签值变化监听器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22740585/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 17:36:24 来源:igfitidea点击:
How implement javafx label value change listener
提问by java baba
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");
}
回答by java baba
well i found the answer after some rnd here is code
好吧,我在一些 rnd 之后找到了答案,这里是代码
myLabel.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> ov, String t, String t1) {
System.out.println("Label Text Changed");
}
});