CSC1120 Week 2 Homework

Overview

Using JavaFX, write a simple calculator program that looks something like this:

calculator

Details

Formatting

HBox innerPane = new HBox();
.
.
.
innerPane.getChildren().addAll(firstOperand, operator, secondOperand, equals);
.
.
.
VBox pane = new VBox();
.
.
.
pane.getChildren().addAll(innerPane, result);

VBox

HBox

TextField

Spacing vs Padding

JavaFX and TestFX

To run and test JavaFX programs, there are separate libraries similar to JUnit that are needed to run and test programs using JavaFX, which is not part of the base Java language. Testing FX programs does not work in GitHub, since there is no actual graphical desktop there, but you can run these tests in IntelliJ to verify your program is working as intended.

You should have already configured IntelliJ to run JavaFX. If you have not, use the Taylorial on JavaFX to get it installed and configured, then read on.

In the repository, you have a lib folder where a number of .jar files are located. These are all separate Java libraries that you can add to your project and where the TestFX libraries are. To add them to the project so you can use them do the following:

Your Dependencies should now look like this: TestFX3

and you should be able to run the tests as normal. You will see your program open and a "robot" running through the tests. Don't try and move the cursor or type anything while this is testing, or you may interrupt the tests.