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 answer text field
- The background color of the result text field 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 text fields should also add the numbers together.
- If either of the operand text fields are empty, nothing should happen.
- Exception handling should print a useful message to the console.
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