gpt4 book ai didi

java - 通过fxml添加EventFilter

转载 作者:行者123 更新时间:2023-12-02 06:02:11 25 4
gpt4 key购买 nike

现在我可以做到

public TextField lastmonthbox;
public void initialize()throws Exception{
lastmonthbox.addEventFilter(KeyEvent.KEY_TYPED, new EventHandler<KeyEvent>() {
public void handle( KeyEvent t ) {
char ar[] = t.getCharacter().toCharArray();
char ch = ar[t.getCharacter().toCharArray().length - 1];
if (!(ch >= '0' && ch <= '9' || ch=='.')) {
System.out.println("The char you entered is not a number");
t.consume();
}
}
});

}

有没有办法通过fxml添加事件过滤器,看起来像onAction =“#someFunction”??

我没有找到任何关于 fxml 中所有可能标签的列表或教程(

最佳答案

据我所知不可以,但您始终可以根据您的需要自定义控件。例如像

<MyTextField ... onKeyTypedFilter="#yourFilter" />

然后在后端做一些反射工作。但这值得吗?

关于java - 通过fxml添加EventFilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22589901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com