validate() method is used to verify the legality of components and sub-components. It is verified according to InputVerifier. The return value is a Boolean value, indicating whether it is valid: calculate the optimal size and re-layout. Iterate through the child components and call their validate() method. Call InputVerifier to verify the input: if validation fails, the mark is invalid and false is returned. If the verification is successful, the tag is valid and true is returned.
##Usage of validate() method in Java
validate() Method in In Java, it is a method defined in the
Component class and all its subclasses. It is used to check the validity of a component and its subcomponents and validate them against the component's
InputVerifier settings.
Usage
##validate() The method is called as follows: <pre class="brush:php;toolbar:false"><code class="java">public boolean validate()</code></pre>
validate()
The method returns a Boolean value indicating whether the component and its subcomponents are all valid. Returns true
if all components are valid; otherwise, returns false
.
validate()
method is usually used in the following situations:
When the
validate() method is called, it will perform the following steps:
For each subcomponent of the component, call its
Call the InputVerifier
(if it exists).
If verify()
method to verify the input of the component.
returns false
), the component will be marked as invalid and the validate()
method will Return false
. Otherwise, the component will be marked as valid and the validate()
method will return true
.
Call
or
FocusEvent handler ()
method to ensure validation when the user enters or changes focus.
Create a custom
Use
The above is the detailed content of How to use validate() in java. For more information, please follow other related articles on the PHP Chinese website!