Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE READ CAREFULLY! Develop a simple Java GUI, including two JTextFields and one JButton. The first text field is for name input and the second
PLEASE READ CAREFULLY!
Develop a simple Java GUI, including two JTextFields and one JButton. The first text field is for name input and the second is for age input. There is a separate Utility class that equips two methods checkName() and checkAge() to verify name and age, respectively. The following criteria must hold. Submit your program to the Canvas drop box.
- The name cannot be zero character or longer than 15 characters. A character can be either a space, a dash -, an alphabet, or a ,. No other characters or digits are allowed; otherwise, a name exception is thrown to the output or command prompt window.
- The age must be between 0 and 100 inclusively; otherwise, an age exception is thrown in a similar manner.
- An exception object e should be caught in a try/catch clause and printed using System.out.println(e) command.
- The System.out.println(e) for name exception will show one of the following three exception messages. The priority is based on the listed sequence.
- NameException: 0 <= (30) characters <= 15 is invalid. Note that the number 30 depends on the actual user input.
- NameException: a special character exists.
- NameException: a digit exists.
- The System.out.println(e) for age exception will show an out-of-bound error message like AgeException: 0<= (155) <= 100 is invalid. The value 155 depends on the actual user input.
- The Jbutton should only be clickable once both JTextField inputs are valid
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started