Whenever a user presses the search button and the SearchView component is shown, it goes back to the button MenuItem once a query is submitted.
However, when a user press the Back key, only the keyboard is hidden but the SearchView component is still visible. If you press the Back key again, one would expect the SearchView to be iconified but the app exits instead.
The workaround for this is to add an OnFocusChangeListener to the SearchView component. Whenever the keyboard gets shown and hidden, the onFocusChange() method gets called.
You wonder in your Java Swing application why after pressing the TAB key and the next button has focus, nothing happens when you press the ENTER key. Then you find out only the SPACE key works. The culprit here is the look and feel.
The ENTER key works only in the Windows look and feel. Other look and feel themes have the SPACE character as its ENTER representation. If you want to mimic the ENTER key instead of the SPACE key even though your look and feel theme is not Windows, here is how you do it.