Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java Develop a simple Java GUI, including two JTextFields and one JButton. The first text field is for name input and the second is for

java

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. o NameException: 0 <= (30) characters <= 15 is invalid. Note that the number 30 depends on the actual user input. o NameException: a special character exists. o 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.

Input Verifier Hint: jTextField1.setInputVerifier(new InputVerifier() { @Override public boolean verify(JComponent input) { JTextField jtf = (JTextField) input; // The text field stays focused if containing a character a. if (jtf.getText().indexOf("a") > -1) { return false; } else { return true; } } });

It should have:

correctness of exception handling button is clickable only and instantly when both fields have valid inputs. having focus control when data inputs instantly become correct or incorrect.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

Identify the elements that make up the employee reward package.

Answered: 1 week ago

Question

Understand the purpose, value and drawbacks of the interview.

Answered: 1 week ago