Question

this is the method I'm using to test this:

     private void searchFieldKeyTyped(java.awt.event.KeyEvent evt) {                                     
        String query = searchField.getText();
        System.out.println(query);
     } 

if i type one letter though, query contains an empty string if i type another letter, query contains the single previous letter

so if i type "a", query is empty
If I type "ab", query contains "a"
If i type "abc", query contains "ab"
If I type "abcd", query contains "abc"
and so on.

Was it helpful?

Solution

As discussed in the comments, use KEY_RELEASED rather than KEY_PRESSED.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top