CSC1020 Homework 3
Overview
Using JavaFX, write a simple calculator program that looks something like this:
Details
- The program will display the result of adding two integers together when the equals button is clicked.
- The user cannot modify the result TextField
- The background color of the result TextField is red if the result is negative, otherwise the background should be light grey, as shown above and below.
- Hitting enter when in either of the operand TextFields should also add the numbers together.
- If either of the operand TextFields are empty nothing should happen.
- If either TextField contains a non-integer value, an error message should be displayed in the result TextField and the background of the TextField should be red.
Formatting
- For organizing your Scene, try creating an HBox object and put the upper row of components in the HBox, in the order they will appear.
- Create a VBox object and put the HBox object and the answer TextField in that
- Use the VBox as the main container for your Scene.
- It will look something like this:
HBox innerPane = new HBox(); . . . innerPane.getChildren().addAll(firstOperand, operator, secondOperand, equals); . . . VBox pane = new VBox(); . . . pane.getChildren().addAll(innerPane, result);
- Play around with the padding and spacing of the VBox and HBox to line it up the way you would like it
- Below are links to some useful javadoc pages