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

Project 8 Template

Posted on April 24, 2020 By William Jojo
Uncategorized

Regardless of which version you choose, this code will help get you started!

import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.TextAlignment;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
//import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.geometry.HPos;

  
public class Project8_template extends Application 
{ 
  
  public static int cel2far(int c) {
    return c * 9 / 5 + 32;
  }
  
  public static int far2cel(int f) {
    return ( f - 32 ) * 5 / 9;
  }
  
  @Override
  public void start(Stage primaryStage) {
    Label l1, l2; 
    TextField tf1, tf2;
    Button b1, b2;
    GridPane pane = new GridPane();
    Scene scene = new Scene(pane, 500, 200);

    
    b1.setOnAction( event -> {
      // button work goes here.
    });
    
    /*
    If you are doing 8a, with two buttons, this is for the second button.
    
    b2.setOnAction ( event -> {
      // button work goes here.
    });
    */
    
    System.out.println(pane);
    primaryStage.setTitle("Temperature Conversion");
    primaryStage.setScene(scene);
    primaryStage.show();
  } 
    
  public static void main(String[] args) {
    launch(args);
  }
} 

Post navigation

❮ Previous Post: CISS-150 Project 7 – RAID
Next Post: Overview ❯

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

Copyright © 2018 – 2025 Programming by Design.