Question: code in JAVA 1.Create a GUI that allows the user to enter the distance in miles to be converted to Kilometers. You GUI should have

code in JAVA

1.Create a GUI that allows the user to enter the distance in miles to be converted to Kilometers. You GUI should have the following:

A title Distance Conversion

A textfield of length 15 with a label Distance next to it

A textfield of length 15 with a label Converted Distance next to it

A button with the text Convert to KM

A button with the text Convert to Miles

A background color of Cyan

The buttons foreground color of blue

2.

Modify the 1st to implement the ActionListener for the 2 buttons (Convert to Miles and Convert to KM). The textfield (with label Converted Distance) should be populated with the converted distance. Use the setText() method to change its content.

Add two radio buttons after the Distance textfield with labels Miles and KM. This indicates the units of the Distance textfield.

Add the radio buttons to a ButtonGroup

If the user selects the Miles radio button and tries to convert to Miles, it should return the same distance (in miles). Similarly, if the user selects the KM radio button and tries to convert to KM, it will return the same value.

3.

Modify 2nd to use any Layout Manager (except FlowLayout) that you see appropriate.

Add a checkbox at the bottom Allow same unit conversion.

If the checkbox is checked and the user chooses to convert miles to miles (or km to km), it will allow them and just display the samedistance. This is the same behavior as last classwork.

If the checkbox is Unchecked, an error message will be displayed Same unit conversion not allowed.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!