Java Modify this program and Add buttons for all the numbers in a calculator (0-9). Look at a calculator application to make sure you place the buttons correctly. Add buttons for addition, subtraction, multiplication and division. Add a button for the equal sign "=".

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Java

Modify this program and

Add buttons for all the numbers in a calculator (0-9). Look at a calculator application to make sure you place the buttons correctly.

Add buttons for addition, subtraction, multiplication and division.

Add a button for the equal sign "=".

package myJavaFXpkg;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.Border;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;

public class MyJavaFX extends Application
{
@Override // Override the start method in the Application class
public void start(Stage primaryStage) throws Exception
{
double sum = 45.6;

// Create a scene and place a button in the scene.
Pane pane = new Pane();
Button btOK = new Button("OK");
btOK.setLayoutX(20);
btOK.setLayoutY(80);
pane.getChildren().add(btOK);

Button SecondBtn = new Button("Second");
SecondBtn.setLayoutX(100);
SecondBtn.setLayoutY(80);
pane.getChildren().add(SecondBtn);

Label myLabel = new Label("123456");
myLabel.setFont(Font.font("Courier",FontWeight.BOLD,FontPosture.REGULAR,20));
myLabel.setStyle("-fx-border-color: blue;");
myLabel.setAlignment(Pos.BASELINE_RIGHT); // align text to the right side of the label.
myLabel.setLayoutX(10); // set the x location of the label
myLabel.setLayoutY(10); // set the y location of the label
myLabel.setPrefSize(250, 20); // set the width and height of the label
myLabel.setText("123456789"); // put some numbers into the label
pane.getChildren().add(myLabel);
myLabel.setText(Double.toString(sum));

Scene scene = new Scene(pane,280,300);
primaryStage.setTitle("MyJavaFX"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
}

public static void main(String[] args)
{
launch(args);
}
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY