Skip to content

Programming by Design

If you're not prepared to be wrong, you'll never come up with anything original. – Sir Ken Robinson

  • About
  • Java-PbD
  • C-PbD
  • ASM-PbD
  • Algorithms
  • Other

CISS-110 Project 8a – JavaFX

Posted on September 19, 2019January 20, 2025 By William Jojo
CISS-110-Project
CISS-110 Project 8a

Write a Java program to create a GUI using JavaFX with GridPane, TextField, Label, and Button objects. This is a continuation of Project 7, which used the text-based menu-driven model.


Learning outcomes

  • Implementing user-defined methods.
  • Working with JavaFX.
  • Working with events.
  • Confirmation program produces desired results.

Write two value-returning methods called farToCel() and celToFar(). These two methods will convert temperatures from Fahrenheit to Celsius and Celsius to Fahrenheit. They will each take a single int parameter and return the converted value as an int. (These should already be done and can be taken from Project 7. No other code from Project 7 will be of any consequence.)

Here is a picture of what you will create:

Project 8

In your start() method, do the following:

  • Create two labels “Temperature:” and “Results:” that are centered.
  • Create two text fields with:
    • A maximum width of 200 for each.
    • The temperature text field should be initially set to zero.
    • The results text field has no initial value and should not be an editable field.
  • Create two buttons, “Celsius to Fahrenheit” and “Fahrenheit to Celsius.” The right-hand button should be right-aligned
  • Set the window title to “Celsius and Fahrenheit Conversion”
    • Set the layout to the GridPane layout. Make the hgap and vgap values 10.
    • Add the temperature label and text field.
    • Add the buttons.
    • Add the result label and text field.
  • Assign the button handlers using the Lambda Expression method.
  • Set the window size to 500 pixels wide by 200 pixels high.

For the button handlers, you should perform the following:

  • Read the temperature text field value.
  • Convert the String temperature to an integer.
  • Convert the temperature from one scale to the other.
  • Display the relative information in the results text field.

For 5 points of extra credit, read the try/catch section of Chapter 12 and do not allow non-numeric quantities for Temperature text field and display an error in the Result text field like so:

Project 8 extra credit

You must include this in the final program when submitted.


Submit the project to the Learning Management System as Project8_lastname.java.

Post navigation

❮ Previous Post: Appendix B – Undefined Behavior
Next Post: CISS-150 – Threads ❯

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Copyright © 2018 – 2025 Programming by Design.