During a focus transfer, is there a way to validate dependent fields such that a focus transfer among JComponents (a, b, c) is not vetoed but a focus transfer to some external element (say, d) is vetoed?
The most natural place to do such a thing seems to be in InputVerifier.shouldYieldFocus(); however, I don't see a way to obtain the (next) focus target at that time.
Not supported by the InputVerifier mechanism. And probably shouldn't at that level of granularity because it might lead to giving focus to d with invalid data in a.
Assume an InputVerifier which does know the opposite component (that is the potential next focusOwner) and its data is invalid
(same overall effect with Rob's suggestion, btw, except that the a's InputVerifier is never run)
On the whole, the built-in validation support isn't very strong - lots of work left for the developer. Some things you would need to do
Using a framework like f.i. JGoodies Validation might be easier.
For the dependent components you should be able to use:
component.setVerifyInputWhenFocusTarget( false );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With