< prev index next >
src/java.desktop/share/classes/javax/swing/InputVerifier.java
Print this page
*** 32,47 ****
* navigation through GUIs with text fields. Such GUIs often need
* to ensure that the text entered by the user is valid (for example,
* that it's in
* the proper format) before allowing the user to navigate out of
* the text field. To do this, clients create a subclass of
! * <code>InputVerifier</code> and, using <code>JComponent</code>'s
! * <code>setInputVerifier</code> method,
! * attach an instance of their subclass to the <code>JComponent</code> whose input they
* want to validate. Before focus is transfered to another Swing component
! * that requests it, the input verifier's <code>shouldYieldFocus</code> method is
! * called. Focus is transfered only if that method returns <code>true</code>.
* <p>
* The following example has two text fields, with the first one expecting
* the string "pass" to be entered by the user. If that string is entered in
* the first text field, then the user can advance to the second text field
* either by clicking in it or by pressing TAB. However, if another string
--- 32,47 ----
* navigation through GUIs with text fields. Such GUIs often need
* to ensure that the text entered by the user is valid (for example,
* that it's in
* the proper format) before allowing the user to navigate out of
* the text field. To do this, clients create a subclass of
! * {@code InputVerifier} and, using {@code JComponent}'s
! * {@code setInputVerifier} method,
! * attach an instance of their subclass to the {@code JComponent} whose input they
* want to validate. Before focus is transfered to another Swing component
! * that requests it, the input verifier's {@code shouldYieldFocus} method is
! * called. Focus is transfered only if that method returns {@code true}.
* <p>
* The following example has two text fields, with the first one expecting
* the string "pass" to be entered by the user. If that string is entered in
* the first text field, then the user can advance to the second text field
* either by clicking in it or by pressing TAB. However, if another string
*** 101,130 ****
* Checks whether the JComponent's input is valid. This method should
* have no side effects. It returns a boolean indicating the status
* of the argument's input.
*
* @param input the JComponent to verify
! * @return <code>true</code> when valid, <code>false</code> when invalid
* @see JComponent#setInputVerifier
* @see JComponent#getInputVerifier
*
*/
public abstract boolean verify(JComponent input);
/**
! * Calls <code>verify(input)</code> to ensure that the input is valid.
* This method can have side effects. In particular, this method
* is called when the user attempts to advance focus out of the
* argument component into another Swing component in this window.
! * If this method returns <code>true</code>, then the focus is transfered
! * normally; if it returns <code>false</code>, then the focus remains in
* the argument component.
*
* @param input the JComponent to verify
! * @return <code>true</code> when valid, <code>false</code> when invalid
* @see JComponent#setInputVerifier
* @see JComponent#getInputVerifier
*
*/
--- 101,130 ----
* Checks whether the JComponent's input is valid. This method should
* have no side effects. It returns a boolean indicating the status
* of the argument's input.
*
* @param input the JComponent to verify
! * @return {@code true} when valid, {@code false} when invalid
* @see JComponent#setInputVerifier
* @see JComponent#getInputVerifier
*
*/
public abstract boolean verify(JComponent input);
/**
! * Calls {@code verify(input)} to ensure that the input is valid.
* This method can have side effects. In particular, this method
* is called when the user attempts to advance focus out of the
* argument component into another Swing component in this window.
! * If this method returns {@code true}, then the focus is transfered
! * normally; if it returns {@code false}, then the focus remains in
* the argument component.
*
* @param input the JComponent to verify
! * @return {@code true} when valid, {@code false} when invalid
* @see JComponent#setInputVerifier
* @see JComponent#getInputVerifier
*
*/
< prev index next >