Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this assignment, I have to write a user interface for your calculator using JavaFX. For this assignment, the GUI does (not)

I need help with this assignment,

I have to write a user interface for your calculator using JavaFX. For this assignment, the GUI does (not) need to respond to any other user input. Note that we are developing this GUI completely separately from any class. This is a common design pattern that is often called ModelView-Controller, or MVC. The model is the data your program deals with, the view is the user interface, and the controller responds to input from the view by acting on the data in the model.

The code below makes up an unorganized GUI, The buttons should stick to each other in 4 row and 4 columns, where the fourth column have the signs(/,*,-,+).

package javafxapplication2;

import java.awt.Color; import java.util.ArrayList; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.HPos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; import javafx.scene.layout.RowConstraints; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException;

public class Calculator extends Application{ private boolean operatorAlreadyPressed = false; private boolean secondOperand = false; private boolean scriptExceptionOccurred = false; public static void main(String[] args){ Application.launch(args); } public void start(Stage primaryStage) throws ScriptException{ int windowWidth = 190; int windowHeight = 250; primaryStage.setTitle("Calculator"); primaryStage.setWidth(windowWidth); primaryStage.setHeight(windowHeight);

VBox root = new VBox(); Scene scene = new Scene(root, windowWidth, windowHeight, javafx.scene.paint.Color.WHITE);

Label expressionLabel = new Label();

GridPane numberGrid = new GridPane(); numberGrid.setHgap(5); numberGrid.setVgap(5);

GridPane operatorGrid = new GridPane(); operatorGrid.setHgap(5); operatorGrid.setVgap(5); ArrayList

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

Students also viewed these Databases questions

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago