回车触发事件
querybox.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if(event.getCode() == KeyCode.ENTER){
showHistoryWords(querybox.getText());
}
}
});
属性触发事件
textField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
statusBarLabel.setText("状态:当前字符数为:" + textField.getText().length());
}
});