Project UI Design and Navigation
Explanation (with File Handling)
1. Login Screen
Components:
- Label: "Username", "Password"
- TextField: for entering username
- PasswordField: for entering password
- Button: "Login"
Behavior:
- When the user clicks "Login":
- If the credentials match (from a file), the user is directed to the Main Dashboard.
- If credentials are incorrect, an error message appears.
2. Main Dashboard
Components:
- Label: Screen Title
- Button: "Manage Lectures"
- Button: "Enter Grades"
- Button: "Logout"
Behavior:
- "Manage Lectures" opens the Lecture Management Screen.
- "Enter Grades" opens the Grade Submission Screen.
- "Logout" returns to the Login Screen.
3. Lecture Management Screen
Components:
- TableView: Displays list of lectures
- TextField: For entering lecture name
- ComboBox: For selecting the academic group (e.g., First Year)
- Button: "Add Lecture"
- Button: "Delete Lecture"
Behavior:
- When clicking "Add Lecture", the data is saved to a file and the table updates.
- "Delete Lecture" removes the selected lecture from the file and UI.
4. Grade Submission Screen
Components:
- Label: "Student Name", "Lecture Name"
- TextField: For entering grade
- Button: "Submit Grade"
- TableView (Optional): Shows submitted grades
Behavior:
- "Submit Grade" saves the input to a file related to the student or lecture.
- Success message is displayed after saving.
5. Navigation Map
From -> Click -> To
Login Screen -> Login -> Main Dashboard
Main Dashboard -> Manage Lectures -> Lecture Management Screen
Main Dashboard -> Enter Grades -> Grade Submission Screen
Any screen -> Logout -> Login Screen
6. File Handling Example
In this section, we will use JavaFX to store lecture data in a file.
We will utilize the TextField for input and a Button for saving the lecture name.
Java Code Example:
1. Define the TextField and Button:
TextField lectureNameField = new TextField();
lectureNameField.setPromptText("Enter Lecture Name");
Button saveButton = new Button("Add Lecture");
2. Define the save functionality:
saveButton.setOnAction(e -> {
String lectureName = lectureNameField.getText();
try {
FileWriter writer = new FileWriter("lectures.txt", true); // true to append data to the
file
writer.write(lectureName + "\n");
writer.close();
System.out.println("Lecture saved.");
} catch (IOException ex) {
ex.printStackTrace();
}
});
3. Add them to the layout:
VBox layout = new VBox(10);
layout.getChildren().addAll(lectureNameField, saveButton);