Java - Single Field Validation
Java includes the AWT class ("Abstract Windows Toolkit") which
provides several components that are useful for single field validation.
Some of these components are:
- TextField and TextArea
- Checkbox and CheckboxGroup
- Choice
- List
- Button
- Menu and MenuItem
- Label
Using these GUI components and a little Java code it is possible to
validate many different types of User input for individual fields. In fact,
the Choice, List, and Checkbox components provide validation by simply
limiting the Users options to the values that you provide when creating
the component in Java.
ADVANTAGES:
- Java AWT can be used to create similar forms to what you can create in HTML.
- You can create Forms that adjust dynamically to User actions. (Hide or Disable
a component). You can not do this with the static displays created by HTML or with
JavaScript.
- You can create a more interactive interface by catching mouse movements and
key strokes. Again this can not be done with HTML and JavaScript.
- Several Java GUI components provide validation by their very nature! A
Choice is just that. The User can only choose one.
DISADVANTAGES:
- Java Applets can not easily display dialog boxes which are very helpful in
providing feedback to the user. This is because the Applet can not get the
"handle" to the window that it is running in. (Note: there may be a few
tricks to get around this but it requires much more code than JavaScript.)
- It is very difficult to organize different sized components within the
Applets screen space. There is no absolute positioning of components. You
must use built in layout managers.
- Requires Java support by Browsers.
The examples provided below demonstrate some of these components:
Example of Individual Components in Separate
Applets
Example of Several Components in a Single Applet