Re: How to detect focus lost on a JPanel




Jeff Higgins wrote>
Ian Wilson wrote:
clearlight@xxxxxxxxx wrote:
Inside any of this panels, there are JTextFields that have to be
validated (via InputVerifiers).

Now, if focus is inside any of this JTextFields, and I select a new
option from the frame's menu, validation shouldn't be fired.



I had a similar problem, an input panel with OK and Cancel buttons. If
the user is editing a JTextField then clicks Cancel, you don't want the
validation to kick in. I used this approach:

cancelButton.setVerifyInputWhenFocusTarget(false);

In your shoes I'd read the docs to see if
.setVerifyInputWhenFocusTarget(false) can be applied to your JMenuItems


Strange, that JMenu, JMenuBar don't seem to honor
.setVerifyInputWhenFocusTarget(false)

I could only get your suggestion to work using:
f.getRootPane().setVerifyInputWhenFocusTarget(false);
as below. I don't know what implications that may hold.
What about pop-up context menus?

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4403182


.


Quantcast