in the attached code the line to display “Record #” will no longer display. I added final grade and letter grade and then record # dissapears.
//Set properties of UI Nodes
tfCourse.setEditable(false);
tfLastName.setEditable(false);
tfFirstName.setEditable(false);
tfQuiz1.setEditable(false);
tfQuiz2.setEditable(false);
tfQuiz3.setEditable(false);
tfMidterm.setEditable(false);
tfFinal.setEditable(false);
tfFinalGrade.setEditable(false);
tfLetterGrade.setEditable(false);
GridPane.setHalignment(butPrevious, HPos.LEFT);
GridPane.setHalignment(butNext, HPos.RIGHT);
GridPane.setHalignment(lblRecordNumber, HPos.RIGHT);
Scene mainScene = new Scene(centerPane, 400, 450);
primaryStage.setTitle("Student Record Viewer");
primaryStage.setScene(mainScene);
primaryStage.show();
}
public Project03() {
tfCourse = new TextField();
tfLastName = new TextField();
tfFirstName = new TextField();
tfQuiz1 = new TextField();
tfQuiz2 = new TextField();
tfQuiz3 = new TextField();
tfMidterm = new TextField();
tfFinal = new TextField();
tfFinalGrade = new TextField();
tfLetterGrade = new TextField();
lblRecordNumber = new Label();
currentRecordIndex = 0;
} //Project03 Constructor
private EventHandler<ActionEvent> defineActionEvent(final String forNode) {
EventHandler<ActionEvent> theHandlerObject = null;
theHandlerObject = new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
switch (forNode) {
case "PreviousButton":
if (currentRecordIndex > 0) {
currentRecordIndex–;
setFields(currentRecordIndex);
} else {
System.out.println("Reached BEGINNING of Records.");
}
break;
case "NextButton":
if (currentRecordIndex < (fileRecords.size() – 1)) {
currentRecordIndex++;
setFields(currentRecordIndex);
} else {
System.out.println("Reached END of Records.");
}
break;
default:
System.out.println("Error. Undefined object.");
break;
}
}
};
return theHandlerObject;
} //defineActionEventdefineActionEvent() method.
private static ArrayList<String> getRecords() throws Exception {
ArrayList<String> theRecords = new ArrayList<>();
Scanner inputFile;
inputFile = new Scanner(new File("studentdata.txt"));
while (inputFile.hasNextLine()) {
theRecords.add(inputFile.nextLine());
}
return theRecords;
}
private void setFields(int theIndex) {
String fields = fileRecords.get(theIndex).split(",");
tfCourse.setText(fields[0]);
tfLastName.setText(fields[1]);
tfFirstName.setText(fields[2]);
tfQuiz1.setText(fields[3]);
tfQuiz2.setText(fields[4]);
tfQuiz3.setText(fields[5]);
tfMidterm.setText(fields[6]);
tfFinal.setText(fields[7]);
tfFinalGrade.setText(fields[8]);
tfLetterGrade.setText(fields[9]);
lblRecordNumber.setText(String.format("Record #%3d", theIndex));
}
/**
* @param args the command line arguments
*/
public static void main(String args) {
launch(args);
}
}