Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a problem that need to create temperature converter GUI, I do write part of it but can't confusing about the rest part. Please

This is a problem that need to create temperature converter GUI, I do write part of it but can't confusing about the rest part. Please help me because this homework is due tommrow! Thanks!(Here is all the information and everything is clear, thanks!)

image text in transcribed

2

image text in transcribed

3

image text in transcribed

1. Complete the following code so that it generates the following temperature converter GUI. (6 pts) | | 3 Temperature Temperature emperature Converter emperature Converter emperature Converter Farenheit 85.5 Farenheit 104.00 Farenheit Celcius 29.72 Celcius 40 Celcius ] Lauri ConvertClea ConvertClear ConvertClear Fig 1: Enter Faren. press "Conver Fig 2: Enter Celcius. press "Convert" Fig 3: press "Clear" import javafx.scene.control import javafx.scene.control. Toxt Field, import javafx.scene.control import javafx.scene.layout.StackPane: import javafx.scene.layout.GridPane; import javafx.scene.layout. HBox; import javafx.geometry. Insets import javafx.geometry. Pos import javafx.event.ActionEvent: import javafx.event.EventHandler; import java.text.DecimalFormat; public class TempConverter extends GridPane private Label instruction, farenLabel, celciusLabel; private TextField tfFaren, tfcelcius; private Button convertBtn, clearBtn; //Constructor public TempConverter ) //Step 1 instantiate all instance variables instruction = new Label ("Temperature Converter"); farenLabe1 = new Label ("Farenheit"); celciusLabelnew Label ("Celcius" ' tfFaren new TextField(); tfCelcius new TextField); convertBtn = new Button ("Convert"); clearBtnnew Button ("Clear" //Create a GridPane and set its properties GridPane gridPanenew GridPane) gridPane.setAlignment (Pos. CENTER) gridPane.setPadding (new Insets (12, 12, 12, 12)); gridPane.setHgap (5); gridPane.setVgap (5) //(1)add labels and text fields inside gridPane gridlane .add Cinstruction , o,o) grid Pane add Cfaren Lolel, o arid Pan?. a nd Pne add t Falen, 1,1> /create a HBox which contains the two buttons jrirn HBox but t on Pane = new HBox (15); buttonPane.setPadding (new Insets (12, 12, 12, 12) buttonPane setAlignment (Pos.CENTER; // (2) add two buttons inside buttonPane button Panc addlCcovertta button Pane.add ( clearBtn // (3) TempConverter is a GridPane. Add the relevant GUI component inside //(4) register the source object with a nw handler object l //end of the constructor //step #2: The handler class private class TempHandler implements EventHandler public void handle (ActionEvent e) double farenNum, celciusNum; DecimalFormat fmt new DecimalFormat ("0.00". //Check which button is picked object source-e.getSource) if( source-convertBtn && !tfFaren . getText() .trim ( ).isEmpty() tfcelcius.getText.trim).isEmpty) /1(5) handle this case here else if sourceconvertBtn && tfFaren.getText().trim).isEmpty) && tfcelcius.getText).trim).isEmpty)) // (6)handle this case here else if (sourceclearBtn) I //(7)handle this case here else //do nothing for all other cases //end of handle) /end of TempHandler class //The following is the driver program for TempConverter import javafx.application.Application,; import javafx.scene.Scene: import javafx.stage.Stage; import javafx.scene.layout.StackPane; public class TemperatureGUI extends Application public void start (Stage primaryStage) //create a TempConverter pane TempConverter gui -new TempConverter StackPane root Pane new StackPane rootPane.getchildren add (gui); // Create a scene and place rootPane in the stage Scene scene new Scene (rootPane, 250, 180) primaryStage.setTitle("Temperature Converter"); primaryStage.setScene (scene) . primaryStage.show)

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

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

PostgreSQL 10 High Performance Expert Techniques For Query Optimization High Availability And Efficient Database Maintenance

Authors: Ibrar Ahmed ,Gregory Smith ,Enrico Pirozzi

3rd Edition

1788474481, 978-1788474481

More Books

Students also viewed these Databases questions

Question

Networking is a two-way street. Discuss this statement.

Answered: 1 week ago