Coders Packet

Student CGPA Tracker in Java

By K SYAM PRASAD

StudentCGPATracker is a GUI-based application for students to login, view their details, and CGPA and SGPA.

Certainly! Let's go through the code in detail and explain each part:

//1
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.awt.event.ActionEvent;

Java classes and packages //2 public class Std_Login_Home { // Variables for post, sem1, and sem2 // ... public void post() { JOptionPane.showMessageDialog(null, "Notification : " + post); }
The Std_Login_Home class is defined, which represents the main class of the application. Inside the class, there are variables for post, sem1, and sem2, as well as a post() method that displays a notification using a message dialog.
//3 private JFrame frame; private JTextField btnId; private JPasswordField btnPassword; private JTextField btnName; private JTextField btnRoll; private JTextField btnBranch; private JTextField btnSection; private JButton btnlogout; private JTextField cgpa; private JTextField sgpa; private JComboBox comboBox;

The code defines the instance variables for different GUI components that will be used in the application, such as JFrame, text fields, password field, buttons, and combo box. //4 public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Std_Login_Home window = new Std_Login_Home(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }

The main method serves as the entry point of the application. It creates an instance of the Std_Login_Home class and sets the visibility of the frame to true. //5 private void initialize() { frame = new JFrame(); frame.getContentPane().setBackground(new Color(128, 128, 128)); frame.getContentPane().setForeground(new Color(128, 128, 128)); frame.setBounds(100, 100, 822, 511); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null);

The initialize method initializes the frame of the application. It sets the background and foreground colors, the size and position of the frame, and sets the layout to null (absolute positioning). //6 JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, "Student_Details", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel.setBounds(10, 162, 791, 305); frame.getContentPane().add(panel); panel.setLayout(null);
//7 JPanel panel_1 = new JPanel(); panel_1.setBorder(new TitledBorder(null, "CGPA", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_1.setBounds(396, 11, 385, 283); panel.add(panel_1); panel_1.setLayout(null);

Another panel, panel_1, is created to hold the CGPA components. It is positioned within the panel and has a titled border. //8 JLabel lblCgpa = new JLabel("CGPA"); lblCgpa.setFont(new Font("Tahoma", Font.BOLD, 20)); lblCgpa.setBounds(21, 35, 136, 25); panel_1.add(lblCgpa);

A label, lblCgpa, is created and added to panel_1. It displays the text //9 // Similar code for other labels, text fields, and combo boxes... //10 JButton btnlog = new JButton("Login"); btnlog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Code for handling login button click } }); //11 JButton btnlogout = new JButton("Logout"); btnlogout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Code for handling logout button click } }); //12 // Code for handling database connectivity and fetching student details //13 // Code for CGPA calculation and display //14 // Code for handling logout and clearing displayed information

Detail Code:

  1. The code begins with importing the necessary Java classes and packages required for the application, including the Swing classes for GUI components and the JDBC classes for database connectivity.
  2. The 'Std_Login_Home' class is defined, which represents the main class of the application. Inside the class, there are variables for post, sem1, and sem2, as well as a post() method that displays a notification using a message dialog.
  3. The code defines the instance variables for different GUI components that will be used in the application, such as JFrame, text fields, password field, buttons, and combo box.
  4. The 'main' method serves as the entry point of the application. It creates an instance of the 'Std_Login_Home' class and sets the visibility of the frame to 'true'.
  5. The 'initialize' method initializes the frame of the application. It sets the background and foreground colors, the size and position of the frame, and sets the layout to null (absolute positioning).
  6. A panel is created to hold the student details components. It has a titled border and is positioned within the frame.
  7. Another panel, 'panel_1', is created to hold the CGPA components. It is positioned within the 'panel' and has a titled border.
  8. A label, 'lblCgpa', is created and added to 'panel_1'. It displays the text "CGPA" with a specified font and position.
  9. More labels, text fields, and combo boxes are created and added to their respective panels. These components are used to display student details, CGPA, and SGPA.
  10. A login button, 'btnlog', is created with the text "Login". An action listener is added to handle the button click event.
  11. A logout button, 'btnlogout', is created with the text "Logout". An action listener is added to handle the button click event.
  12. Code is added to handle database connectivity using JDBC. It establishes a connection with the database, executes SQL queries to fetch student details and grades, and updates the GUI components accordingly.
  13. Additional code is added to calculate the CGPA based on the fetched grades and display it in the appropriate text field. The code handles the selection of a semester from the combo box to display the corresponding SGPA.
  14. The logout functionality is implemented to clear the displayed student details and CGPA upon clicking the logout button. It also enables the login button and allows the user to enter new credentials.

That's a detailed explanation of the code! It covers the initialization of GUI components, handling login/logout, fetching student details from the database, calculating CGPA, and updating the GUI accordingly.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This project is a Java Swing-based student login system that allows students to access their details and calculate their CGPA (Cumulative Grade Point Average). The system includes the following features:

  1. Login Page: Students can enter their student ID and password to log in to the system.
  2. Student Details: Once logged in, the system displays the student's name, roll number, branch, and section.
  3. CGPA Calculation: The system calculates the CGPA based on the grades obtained in different semesters. It provides a dropdown menu to select the desired semester to display the corresponding SGPA (Semester Grade Point Average).
  4. Semesters and Grades: The system retrieves grades from a MySQL database for each semester. It calculates the CGPA by averaging the SGPA of different semesters.
  5. Logout: Students can log out of the system, which clears the displayed information and allows for a new login session.

Overall, this project provides a basic student login system with the functionality to view student details and calculate the CGPA. It can serve as a starting point for further development and expansion based on specific requirements.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

MySql

Sql Tables

I am using the above tables in SQL for this project.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

=> After completing the project, I will establish a connection between the SQL database and the Java GUI application using JDBC, resulting in a fully functional system.

Before Login -> Application

Login Window

After Login -> Application

Login Successful Page

SGPA CHECKING

Sgpa Check

SGPA

Displayed Sgpa

LOGOUT -> APPLICATION

Logout Successful

Attempting to log in without providing login credentials will result in an authentication error, as the system requires valid credentials for successful login.

Provide Login Details

 

Download Complete Code

Comments

  • Bokkasam Eswarsai (Eswarsai26):

    Nice Work.

    This project is useful for us.

  • Reply to this comment



  • UNDRALLA NITHIN :

    Nice project...it is very useful for students.

  • Reply to this comment



    Download Packet

    Reviews Report

    Submitted by K SYAM PRASAD (Syampk58)

    Download packets of source code on Coders Packet