Viktor Carlson
Viktor Carlson

Reputation: 1008

Java InputVerifier find component who causes the "focus lost"

I have an InputVerifier for a jTextField and of course the InputVerifier is triggered when I loose the focus of the text field for example through clicking on a button.

If I would use a FocusListener I could do:

focusLost(FocusEvent e) {
e.getOppositeComponent()
}

which gives me the component which is the reason that the focus is lost in this case the clicked button.

Is there a way to do something like this in an InputVerifier too ? Basically I need to know if the reason that the InputVerifier is triggered is because a button was pressed.

Upvotes: 0

Views: 260

Answers (1)

camickr
camickr

Reputation: 324098

Basically I need to know if the reason that the InputVerifier is triggered is because a button was pressed.

If you want to prevent the verification when you click a specific button then you can use:

button.setVerifyInputWhenFocusTarget( false );

Upvotes: 2

Related Questions