简体   繁体   English

文本字段的javafx场景构建器动作处理程序

[英]javafx scene builder action handler for text field

I have a method in my controller class for auto completion functionality of text field. 我的控制器类中有一个用于文本字段自动完成功能的方法。 That method is connected to the text field in the scene builder but it's not working because i'm not passing correct parameter for event handling in my method. 该方法已连接到场景构建器中的文本字段,但无法正常工作,因为我没有在方法中传递用于事件处理的正确参数。 I have tried the following: 我尝试了以下方法:

  • autoComplete(ActionEvent event) autoComplete(ActionEvent事件)
  • autoComplete(KeyEvent event) autoComplete(KeyEvent事件)

Can anyone tell what parameter should i pass to fix this problem? 谁能告诉我应该传递什么参数来解决此问题?

Try to listen for change in the text and do the autocompletion logic afterwards 尝试听文本中的更改,然后执行自动补全逻辑

textField.textProperty().addListener( e -> {
    System.out.println(textField.getText());
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM