Question: Java / JavaFX program help package Chapter 1 4 _ Lab _ Solution; import java.text.DecimalFormat; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos;

Java/JavaFX program help package Chapter14_Lab_Solution;
import java.text.DecimalFormat;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class GradeBookFX_Starter_Code extends Application {
// these text fields have to be defined here so the loadTheGrid method can find them.
TextField txAssignmentsPossPoints = new TextField();
TextField txReviewQuizzesPossPoints = new TextField();
TextField txProjectPossPoints = new TextField();
TextField txMidTermPossPoints = new TextField();
TextField txFinalPossPoints = new TextField();
@Override // Override the start method in the APossPointslication class
public void start(Stage primaryStage){
Button btDisplayGrade = new Button("_Display Grade");
btDisplayGrade.setMnemonicParsing(true);
Button btClearAnswers = new Button("_Clear");
btClearAnswers.setMnemonicParsing(true);
Button btnExit = new Button("E_xit");
btnExit.setMnemonicParsing(true);
HBox hBox = new HBox(btDisplayGrade, btClearAnswers, btnExit);
hBox.setSpacing(10);
hBox.setAlignment (Pos.CENTER);
hBox.setPadding(new Insets(5,5,5,5));
BorderPane borderPane = new BorderPane();
borderPane.setTop(hBox);
GridPane gridPane = new GridPane();
gridPane.setAlignment(Pos.CENTER);
ChoiceBox weekChoiceBox.setOnAction(event ->{
loadTheGrid(weekChoiceBox.getValue());
});
// TODO - create the GUI
borderPane.setCenter(gridPane);
btDisplayGrade.setOnAction(e ->{
// TODO - get the points entered by the user - make sure there is data in the
// text field, if it is blank use a zero
// TODO - total the possible points and the points earned so far
// TODO - replace the values to the final version
DecimalFormat df = new DecimalFormat("##.##%");
double percent =(90.0/100.0);
String formattedPercent = df.format(percent);
// next line is for testing only
System.out.println("final grade "+ formattedPercent);
// uncomment next line when you have the text field ready.
txFinalAverage.setText(formattedPercent);
});
btClearAnswers.setOnAction(new EventHandler
Java / JavaFX program help package Chapter 1 4 _

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!