The Java API provides the javax. speech and javax.speech.synthesis packages to develop an application to check the validity of field values specified by an end user in a form.
This chapter describes how to develop a Form Validation application, which converts the validation error text and confirmation message text to speech by using the javax.speech and javax.speech.synthesis packages . This application provides a user interface that contains a blank user information form. The application validates the values provided by an end user in the different fields of the form to check for errors and reads out the validation error text. If the end user enters valid values in the specified fields, the Form Validation application reads out the confirmation message text.
The Form Validation application allows end users to listen to the validation error text in the user information form. When an end user clicks the Save button, the application converts the validation error text to speech.
The Form Validation application uses the following files:
FormValidation.java: Allows end users to enter the user information form. This file also checks whether or not the information specified by an end user is correct.
SpeakFormValidation.java: Converts the validation error text to speech.
Figure 6-1 shows the architecture of the Form Validation application:
The FormValidation.java file provides end users with the user information form, which contains various labels, text boxes, combo boxes, and the Save and Close buttons . This file allows end users to fill the user information form and checks for errors in the form. The FormValidation.java file passes the validation errors to the SpeakFormValidation.java file.
When an end user clicks the Save button, the FormValidation.java file calls the SpeakFormValidation.java file to convert the validation errors passed by the FormValidation.java file to speech.