onFocusLost works only when leaving the window

I have put a (smaller) TextEditor component inside the MainComponent window of the basic GUI example. The call to onFocusLost() works only when clicking outside the window, nothing happens when clicking in the MainComponent but elsewhere than on the TextEditor after having entered some text. Is this the expected behaviour?

Got it: one has to set setWantsKeyboardFocus(true) on the surrounding components in order for this to work.