We help IT Professionals succeed at work.

when I use KeyPress event ,it will invoke the FocusLost event?

lisayan asked
hi everybody,
   I use both FocusLost and KeyPress Event at one JTextField,  when I use "Tab" key to let the JTextField lost focus, it runs ok. but when I use KeyPress Event(such as press "Enter" key), it also runs ok, the problem is that it also execute FocusLost event when I use KeyPress event. anybody  know the reason?
Watch Question

I guess you are showing up a new dialog box or some visual  component "KeyPress" event handler.
In the focuslost(), insert this

  if (evt.isTemporary()) {

Explore More ContentExplore courses, solutions, and other research materials related to this topic.