Current Implementation:
currently the user need to press the Enter key to generate an EventHandler to make my app do something with the input string in the TextField.
textFieldSearchProductNumber.setOnKeyPressed((KeyEvent keyEvent) -> {
if (keyEvent.getCode() == KeyCode.ENTER) {
if (textFieldSearchProductNumber.getText().isEmpty()) {
// ... database query: string content of textFieldSearchProductNumber
}
});
Target:
I would like to make the TextField generate an EventHandler as soon as the user stops the input (Maybe with help of a timer or any other recommendations)
- further input to textfield is observed
-> timer is reset to 500ms and textfield waits again for input - no further input to textfield with timer elapsed
-> textfield pass its content to database search method
How would you go about in writing this sort of code?