The provided code is a Java Swing application that serves as a Student ID Card Generator. It allows users to input student details, upload a picture, generate a preview of the ID card, and download the card as a PNG image. The application also connects to a MySQL database to store the student's information.
- The application uses Java's Swing framework to create the user interface (UI).
- Several input fields such as name, contact number, branch, USN, address, parent's name, Gmail, blood group, and joining year allow the user to enter student information.
- A file chooser is used to upload the student's picture.
- It establishes a connection with a MySQL database using JDBC, where it saves student information. This data includes personal details and the image file path of the uploaded picture.
- Once the information is saved to the database, the application generates an ID card using Java's Graphics class to draw text and the uploaded image onto a
BufferedImage. - It displays the student's details (name, USN, branch, contact info, etc.) on the ID card, and the student image is placed at the top.
- Users can preview the generated ID card in a new window.
- They can also download the ID card as a PNG file using the
ImageIO.writemethod.
- After generating the ID card, the user can choose to edit the details, allowing them to modify the information before finalizing the ID card.
- UI Components: The
JFrameis the main window, and components likeJLabel,JTextField,JButton, andJFileChooserhandle user interactions and input. - Database Handling: The
Connectionobject is used to connect to the MySQL database, andPreparedStatementis used to insert student details into the database. - Image Handling: Student images are uploaded, previewed, and drawn onto the ID card. The ID card itself is generated as a
BufferedImage.
- The user inputs student details and uploads an image.
- The data is saved to the database when "Generate ID Card" is clicked.
- The ID card is created using the provided information and student picture.
- Users can preview the generated ID card.
- The ID card can be downloaded as a PNG file for offline use.
The Project has the follwing structure:
StudentIDGen/
|
|
|----- StudentIDCardDB.db
|
|
|----- StudentIDCardGenerator.java
Below screenshots shows you the output of this project:
After filling the required data like Name, USN, Mobile Number, Parents Name, Place and attaching photo to genarate ID Card.
After hitting the Generate ID Card in USer Inerface it shows an pop-up notification(this time only the details of the student will be processed to store in database StudentIDCardDB.db) that is Student details saved to database
and after hitting the OK button then it will redirect to another tab(which will shows edit information tab) those pages are attached in below.
In the user interface redirect to the editable tab which will help to edit the details. In this page it contaion Preview ID Card, Download ID Card, Edit Details and Genarate ID Card with previous text feilds and buttons. If the user click the Edit Details button it will redirect to the old page. If the user click the Preview ID Card then it will show the Previw of ID Card. This sample is attached here.
After hitting the Generate ID Card that will shows a pop-up notification that picture attached to earlier that the data will be processed to store in database processed in background. that data retrived from the data base using this command:
MySQL Command:
USE StudentIDCardDB
SELECT * FROM student




