Patel Arth Lab6
Patel Arth Lab6
Methodology:
This program provides Java FX application is a calculator with GUI.
First I created a text field where user input the numeric value and add buttons for mathematic
operations. At last Create a GridPane for managing the layout.
##Code
package application;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
@Override
public void start(Stage primaryStage)
{
number1.setPrefWidth(80);
HBox number1Box = new HBox(new Label("FIRST OPERAND"), number1);
number1Box.setAlignment(Pos.CENTER_LEFT);
number1Box.setSpacing(37);
pane.add(number1Box, 0, 0);
number2.setPrefWidth(80);
HBox number2Box = new HBox(new Label("SECOND OPERAND"), number2);
number2.setAlignment(Pos.CENTER_LEFT);
number2Box.setSpacing(18);
pane.add(number2Box, 0, 1);
result.setPrefWidth(80);
HBox resultBox = new HBox(new Label("RESULT"), result);
result.setAlignment(Pos.CENTER_LEFT);
resultBox.setSpacing(77);
pane.add(resultBox, 0, 2);
package application;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.stage.Stage;
@Override
public void start(Stage primaryStage)
{
pane.requestFocus();
}
}
public BB8Pane()
{
line.setStroke(Color.BLACK);
circle1.setFill(Color.CORAL);
circle2.setFill(Color.CORAL);