Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

By completing this Lab, you will practice using JavaFX to create a Graphical User Interface (GUI) and employ event-driven programming. Name your Eclipse project

image text in transcribed image text in transcribed image text in transcribed image text in transcribed

By completing this Lab, you will practice using JavaFX to create a Graphical User Interface (GUI) and employ event-driven programming. Name your Eclipse project Lab3FirstNameLastName. Conversion Calculator Appearance (15 pts) Design and create a GUI that looks similar to Figure 1 below: Conversion Calculator Centimeters 0.0 Meters 0.0 Inches Yards 0.0 Figure 1. Initial GUI before a user's interaction. Create the class Conversion Calculator. The GUI has Labels, Buttons, and TextFields. The GUI uses a combination of VBOX, HBox, and GridPane. Set the title of the GUI to "Conversion Calculator". Clear Calculate Exit Set the initial value of TextFields to 0.00. Do your best to make the GUI look as similar as possible to the examples provided. Some method hints are provided at the bottom of the lab for this. CS161 Introduction to Computer Science II Conversion Calculator Events (15 pts) Implement the following event handling methods to convert units, clear data, and exit the application: Calculate The user can enter a number into the "Inches" TextField and click the "Calculate" Button. Using the following equations, convert the entered length to other units and display them on their corresponding TextFields. 1 inch 2.54 cm 1 inch = 0.0278 yards 0.01 meters 1 cm Centimeters: 0.0 Meters: 0.0 = Conversion Calculator = Centimeters: 25.40 Meters: 0.25 Conversion Calculator All values must be rounded to two decimal places and then displayed. For example, when the user enters 10 in the Inches TextField: Inches: 10 Yards: 0.0 or or or Inches: 10 1 cm 1 yd 1 m Yards: 0.28 = = .3937 inches 36 inches After clicking the Calculate button, the results are rounded to 2 decimal places and displayed: = 100 cm Clear Calculate Exit X Clear Calculate Exit X Note: only calculate using the inches value. If you want, you can disable the other TextFields from manual entry using setEditable (false) for each of them. It will make the other TextFields appear slightly greyed out, which is fine. CS161 Introduction to Computer Science II Clear Exit When the "Clear" Button is clicked, replace the contents of the TextFields with "0.0": Conversion Calculator Centimeters: 0.0 Meters: 0.0 Conversion Calculator Centimeters: 106.05 Inches: 0.0 Meters: 1.06 Yards: 0.0 A second example: when the user enters 41.75 in the Inches TextField and clicks the "Calculate" button, the conversions are displayed as the following: Inches: 41.75 Yards: 1.16 Clear Calculate Exit When the "Exit" Button is clicked, exit the application. X Clear Calculate Exit CS161 Introduction to Computer Science II Hints: Use a combination of HBox, VBox, and GridPane to achieve the layout of the controls. If the controls are sized strangely and very close together, you can adjust using a few methods that are available for most controls: Submit: O set PrefSize(double prefWidth, double prefHeight) Forces the size of the control to be a specific amount of pixels if possible. Use this on Labels, TextFields, and Buttons that you want to look more uniform. I used a (prefWidth, prefHeight) of (230, 45) for each Label+TextField area and (80, 15) for each Button. You can use different values as long as it looks similar. setPadding(new Insets(int padding)) Puts white space (or padding) around the control. Use this on the GridPane to give it some space from the window border. o setHgap(int gap) Puts white space between horizontal controls in a GridPane. Use this on the GridPane to give some space between the different groups of controls. Submit the entire zipped Eclipse project folder containing Lab3 to Brightspace. All source code should be properly documented.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres a basic outline of the ConversionCalculator class in JavaFX to get you started java import javafxapplicationApplication import javafxgeometryIns... 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

Step: 3

blur-text-image

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

Elementary Statistics

Authors: Neil A. Weiss

8th Edition

321691237, 978-0321691231

More Books

Students also viewed these Programming questions

Question

Compute the derivative of f(x)cos(-4/5x)

Answered: 1 week ago

Question

Discuss the process involved in selection.

Answered: 1 week ago

Question

Differentiate tan(7x+9x-2.5)

Answered: 1 week ago

Question

Explain the sources of recruitment.

Answered: 1 week ago