Class InputVerifier

java.lang.Object
vaadinx.swing.InputVerifier

public abstract class InputVerifier extends Object
Port of InputVerifier. Abstract class user code subclasses to validate a field before focus leaves it; we port rather than reuse the JDK class because verify(JComponent) references Component (D_whitelist_porting/D_event_port_policy — types touching the Component hierarchy must live in vaadinx so our emulators can be passed through).

Wired in by JComponent.setInputVerifier(InputVerifier): the peer's blur listener calls shouldYieldFocus(JComponent) on focus-lost; a false return restores focus to the component so the user corrects the field before moving on. The two-arg overload lets a verifier inspect the target of the focus change — in a Vaadin context the target isn't always known (browser focus may go to a non-peer element), so the default falls through to the single-arg form.

  • Constructor Details

    • InputVerifier

      public InputVerifier()
  • Method Details

    • verify

      public abstract boolean verify(JComponent input)
      Check whether the input in input is valid. Returning false prevents focus from leaving the component.
    • shouldYieldFocus

      public boolean shouldYieldFocus(JComponent input)
      Called by JComponent's focus plumbing when focus would leave input. JDK's default delegates to verify(JComponent); override if you want to allow focus to move even when verify fails (e.g. to let the user cancel out via Escape).
    • shouldYieldFocus

      public boolean shouldYieldFocus(JComponent source, JComponent target)
      Two-arg overload that takes the focus target. JDK's default calls the single-arg shouldYieldFocus(JComponent) and drops target — matching so migration code overriding either signature works.