Examine the following code and complete missing parts Square
Examine the following code and complete missing parts:
Square Root
Solution
package squarecalculator;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class SquareCalculator extends Application {
private TextField inputField;
private TextField outputField;
private Button btnSquare;
@Override
public void start(Stage primaryStage) {
inputField =new TextField();
outputField = new TextField();
btnSquare = new Button();
//btnSquare.prefHeight(100);
//btnSquare.prefWidth(100);
btnSquare.setText(\"Get Square\");
VBox box=new VBox(10);
box.autosize();
box.setAlignment(Pos.CENTER);
btnSquare.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
double in=Double.parseDouble(inputField.getText());
outputField.setText(Double.toString(in*in));
}
});
// StackPane root = new StackPane();
box.getChildren().addAll(inputField,outputField,btnSquare);
Scene scene = new Scene(box, 300, 250);
primaryStage.setTitle(\"Hello World!\");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}

