Question: Develop a Java WindowBuilder application with the following specifications. The application will be used to convert from US/British (FPS) measurements to Metric measurements. The application

Develop a Java WindowBuilder application with the following specifications. The application will be used to convert from US/British (FPS) measurements to Metric measurements. The application will convert the following measurements: Miles-Km, Lbs/Kg, Ft/Meters, In/Cm and Deg Celcius/Deg Farenheight. Conversion can be done in both directions (FPS to Metric and Metric to FPS). Provide two TextBoxes, one for the FPS value and One for the Metric value. Depending on which one of the Textboxes the user enters the value in, the type of conversion should be determined. E.g. if Miles are entered, conversion will be done to Km and displayed in the Metric box and vice versa. You need five Buttons: 1) Miles-Km, 2)Lbs/Kg, 3)Ft/Meters, 4)In/Cm and 5)Deg Celcius/Deg Farenheight. When the user enters a value in one of the TextBoxes and clicks one of the 5 buttons, the corresponding conversion should be done and displayed on the OTHER TextBox. Please note that for C/F degree conversion negative numbers are allowed. All other conversions are done only using positive numbers.

I have most of this complete but I can't seem to get it to populate the answer in whichever text field I leave blank. For instance if I enter "1" on the left text field box for "US" measurements, hit the "Pound - KG" button, the right text field where the metric conversion should display remains blank. If I enter a number in both fields it converts fine, but I need to be able to only enter one number. What I have currently for an example of where I am stuck:

public void actionPerformed(ActionEvent e)

{ n1 = textNumber1.getText();

n2 = textNumber2.getText();

num1 = Double.parseDouble(n1);

num2 = Double.parseDouble(n2);

Double pound = (num1 * .45);

Double kgram = (num2 * 2.2);

if(n1.isEmpty())

{ textNumber1.setText((Double)kgram + "");

} else { textNumber2.setText((Double)pound + "");

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!