0% found this document useful (0 votes)
4 views17 pages

OOPM - Report

The document is a mini project report for an ID Card Generator developed in Java at Don Bosco Institute of Technology. It outlines the project's purpose, which is to create a streamlined system for generating ID cards without complex verification processes, focusing on data formatting. The report includes implementation details, results, and concludes that the project successfully meets its objectives.

Uploaded by

Oaish Qazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views17 pages

OOPM - Report

The document is a mini project report for an ID Card Generator developed in Java at Don Bosco Institute of Technology. It outlines the project's purpose, which is to create a streamlined system for generating ID cards without complex verification processes, focusing on data formatting. The report includes implementation details, results, and concludes that the project successfully meets its objectives.

Uploaded by

Oaish Qazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

DON BOSCO INSTITUTE OF TECHNOLOGY

Skill based Lab Course: Object Oriented Programming with Java


MINI PROJECT REPORT

On

“ID Card Generator”


2024-25

Submitted By:

Ansari Mohammed Saif 67


Qazi Mohd Oaish Azher 68
Merchant Mohd Mohiuddin 70

Under the guidance of


Ms. Mayura Gavhane

Inner Title Page


Mini Project Title : ID Card Generator___________________

Institute Name : Don Bosco Institute of Technology.

Institute Address : Premier Automobiles Road,


Kurla (West), Mumbai – 400070
Department : Computer Engineering________________

Class : SE – COMPS B ______________________

Project Group Members :

Names of students Roll No.


1. Ansari Mohammed Saif 67
2. Qazi Mohd Oaish Azher 68
3. Merchant Mohd Mohiuddin 70

Date of Submission : 11/10/2024

Internal Guide
TABLE OF CONTENTS

SR. NO. CONTENT PAGE NO.


CHAPTER 1 INTRODUCTION

CHAPTER 2 PROBLEM DEFINITION


MODULES (IF ANY)

CHAPTER 3 IMPLEMENTATION
CHAPTER 4 RESULTS(SNAPSHOTS)
CHAPTER 5 CONCLUSION
CHAPTER 6 REFERENCES
CHAPTER 1
INTRODUCTION

In the field of software development, there is a growing need to streamline ID card creation using
programming languages that offer flexibility, robustness, and scalability. Java, with its platform
independence, object-oriented structure, and strong graphical capabilities, emerges as a fitting
choice for building such systems. While existing ID card generation systems do address the need for
automated creation and management, they often lack customization, flexibility in design, and the
ability to integrate with external databases and authentication systems seamlessly.

One challenge within this field arises when organizations require rapid generation of ID cards
without the complexity of integrating verification or authentication protocols. In these scenarios,
such as in events or temporary memberships, the focus is on formatting personal data efficiently and
clearly for use in ID badges, labels, or temporary access cards. Here, the complexity of identity
verification can be omitted, leading to a streamlined process that saves both time and resources.
This is where an ID card generator solely for data formatting can contribute meaningfully.

This project proposes a simple ID card generator developed in Java, which takes user input such as
name, cource, and roll number, etc and then formats it into a structured ID card layout without
performing any verification checks. The goal is to create an easy-to-use system that generates ID
cards with consistent formatting, making it suitable for contexts where the emphasis is on
presentation rather than security.

The hypothesis is that a Java-based ID card generator, will meet the needs of users seeking fast and
efficient ID card creation in scenarios that do not require rigorous identity authentication. To test
this, the program was developed to format user input into a standardized card layout, displaying
relevant data in a clear, organized manner.
CHAPTER 2
PROBLEM DEFINITION
CHAPTER 3
IMPLEMENTATION
Main.java:
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.io.*;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import java.awt.image.BufferedImage;

public class Main extends Frame implements ActionListener, ItemListener {

String snameTxt, anoTxt, dobTxt, addTxt, mnoTxt, courseTxt, errStr;


Label lblHead, lblSName, lblANo, lblCourse, lblDOB, lblAdd, lblMNo;
TextField txtSName, txtANo, txtDOB, txtAdd, txtMNo;
Button ViewID, ClearBtn, UploadImage, PrintCard;
Choice ListCourse;
Image logo, profile, baseImg;
boolean Err, reqErr, numErr, nameErr, dobErr;
Vector<TextField> V = new Vector<>();
int offset = 50;

public Main() {
setLayout(null);
setTitle("ID Card Generator");
setSize(380, 710);
setResizable(true);
setLocationRelativeTo(null); // Center the window

ListCourse = new Choice();


ListCourse.add("");
ListCourse.add("CE");
ListCourse.add("IT");
ListCourse.add("ME");
ListCourse.add("EXTC");

lblHead = new Label("Enter Student Details");


lblSName = new Label("Student's Name : ");
lblCourse = new Label("Course : ");
lblANo = new Label("Roll No : ");
lblDOB = new Label("Date of Birth : ");
lblAdd = new Label("Address : ");
lblMNo = new Label("Mobile No. : ");

txtSName = new TextField();


txtANo = new TextField();
txtDOB = new TextField();
txtAdd = new TextField();
txtMNo = new TextField();

ViewID = new Button("View Student ID Card");


ClearBtn = new Button("Clear");
UploadImage = new Button("Upload Profile");
PrintCard = new Button("Print ID Card");

lblHead.setBounds(120, 0 + offset, 200, 20);


lblSName.setBounds(20, 25 + offset, 100, 20);
txtSName.setBounds(120, 25 + offset, 200, 20);
lblCourse.setBounds(20, 50 + offset, 100, 20);
ListCourse.setBounds(120, 50 + offset, 200, 20);
lblANo.setBounds(20, 75 + offset, 100, 20);
txtANo.setBounds(120, 75 + offset, 200, 20);
lblDOB.setBounds(20, 100 + offset, 100, 20);
txtDOB.setBounds(120, 100 + offset, 200, 20);
lblAdd.setBounds(20, 125 + offset, 100, 20);
txtAdd.setBounds(120, 125 + offset, 200, 20);
lblMNo.setBounds(20, 150 + offset, 100, 20);
txtMNo.setBounds(120, 150 + offset, 200, 20);
ViewID.setBounds(120, 190 + offset, 140, 30);
ClearBtn.setBounds(270, 190 + offset, 50, 30);
UploadImage.setBounds(20, 190 + offset, 90, 30);
PrintCard.setBounds(120, 610 + offset, 140, 30);

add(lblHead);
add(lblSName);
add(txtSName);
add(lblCourse);
add(ListCourse);
add(lblANo);
add(txtANo);
add(lblDOB);
add(txtDOB);
add(lblAdd);
add(txtAdd);
add(lblMNo);
add(txtMNo);
add(ViewID);
add(ClearBtn);
add(UploadImage);
add(PrintCard);

ViewID.addActionListener(this);
ClearBtn.addActionListener(this);
UploadImage.addActionListener(this);
PrintCard.addActionListener(this);
ListCourse.addItemListener(this);

logo = Toolkit.getDefaultToolkit().getImage("dbit_logo.png");
profile = baseImg = Toolkit.getDefaultToolkit().getImage("profile.png");
setBackground(Color.white);
Err = false;
reqErr = false;
numErr = false;
nameErr = false;
dobErr = false;
courseTxt = "";
errStr = "";
initVector();

addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
}

public void paint(Graphics g) {


offset = 125;
Color custColor = new Color(208, 159, 46);
g.setColor(custColor);
g.fillRoundRect(15, 280, 350, 365, 30, 30);
custColor = new Color(0, 40, 77);
g.setColor(custColor);
g.fillRoundRect(15, 280, 350, 57, 30, 30);
g.fillRect(15, 290, 350, 47);
custColor = new Color(0, 40, 77);
g.setColor(custColor);
g.fillRect(135, 365, 115, 115);
g.setColor(Color.white);

Err = CheckError();
if (Err) {
if (reqErr) {
g.setColor(Color.red);
g.drawString("*All Fields are Required*", 123, 235);
g.setColor(Color.white);
} else if (numErr || nameErr || dobErr) {
g.setColor(Color.red);
g.drawString("Error : " + errStr, 80, 235);
g.setColor(Color.white);
}
}
g.setFont(new Font("Bahnschrift Semi Bold", Font.BOLD, 15));
initTxt();
g.drawString("The Bombay Salesian Society", 110, 305);
g.drawString("Don Bosco Institute of Technology", 90, 325);
g.drawString("IDENTITY CARD", 135, 355);
g.drawString("Student's Name : " + snameTxt, 25, 377 + offset);
g.drawString("Course : " + courseTxt, 25, 402 + offset);
g.drawString("Roll No : " + anoTxt, 25, 427 + offset);
g.drawString("Date of Birth : " + dobTxt, 25, 452 + offset);
g.drawString("Address : " + addTxt, 25, 477 + offset);
g.drawString("Mobile No. : " + mnoTxt, 25, 502 + offset);

g.drawImage(logo, 30, 283, this);


g.drawImage(profile, 135, 365, this);
}

public void itemStateChanged(ItemEvent e) {


if (e.getSource() == ListCourse) {
courseTxt = ListCourse.getSelectedItem();
}
}

public void actionPerformed(ActionEvent e) {


if (e.getSource() == ClearBtn) {
clear();
return;
} else if (e.getSource() == ViewID) {
viewID();
} else if (e.getSource() == UploadImage) {
uploadImage();
} else if (e.getSource() == PrintCard) {
extractImage(15, 280, 350, 365);
}
numErr = false;
nameErr = false;
dobErr = false;
for (TextField txt : V) {
VerifyText(txt);
}
repaint();
}

public boolean isEmpty(TextField txt) {


String text = txt.getText();
return text.equals("");
}

public void VerifyText(TextField txt) {


if (txt == txtSName) {
String pattern = "^([a-zA-Z ]+)$";
String input = txt.getText();
Boolean result = Pattern.matches(pattern, input);
if (!result) {
nameErr = true;
errStr = "Please Enter A Valid Name";
}
} else if (txt == txtDOB) {
String ptrn = "^(0?[1-9]|[1|2][0-9]|3[01])\\/(0?[1-9]|1[0-2])\\/(19[0-9]{2}|20[0-1][0-9]|202[0-
3])$";
String in = txt.getText();
Boolean result = Pattern.matches(ptrn, in);
if (in.contains("31/02") || in.contains("30/02") || in.contains("31/04") || in.contains("31/06")
|| in.contains("31/09") || in.contains("31/11")) {
result = false;
}
if (in.contains("31/2") || in.contains("30/2") || in.contains("31/4") || in.contains("31/6")
|| in.contains("31/9")) {
result = false;
}
if (result) {
ptrn= "^(0?[1-9]|[1|2][0-9]|3[0])\\/(0?[1-9]|1[0-2])\\/(19[0-9]{2}|20[0-1][0-9]|202[0-3])$";
in = txt.getText();
result = Pattern.matches(ptrn, in);
}
if (!result) {
dobErr = true;
errStr = "Please Enter A Valid Date (dd/mm/yyyy)";
}
} else if (txt == txtMNo) {
String pattern = "^[0-9]{10}$";
String input = txt.getText();
Boolean result = Pattern.matches(pattern, input);
if (!result) {
numErr = true;
errStr = "Mobile Number Should be of 10 Digits";
}
} else if (txt == txtANo) {
String pattern = "^[0-9]+$";
String input = txt.getText();
Boolean result = Pattern.matches(pattern, input);
if (!result) {
numErr = true;
errStr = "Roll No Should be Numeric";
}
}
}

public void initVector() {


V.add(txtSName);
V.add(txtANo);
V.add(txtDOB);
V.add(txtAdd);
V.add(txtMNo);
}

public void clear() {


txtSName.setText("");
txtANo.setText("");
txtDOB.setText("");
txtAdd.setText("");
txtMNo.setText("");
ListCourse.select(0);
courseTxt = "";
reqErr = false;
numErr = false;
nameErr = false;
dobErr = false;
errStr = "";
repaint();
}

public boolean CheckError() {


if (reqErr || numErr || nameErr || dobErr) {
return true;
} else {
return false;
}
}

public void viewID() {


for (TextField txt : V) {
if (isEmpty(txt)) {
reqErr = true;
}
}
if (ListCourse.getSelectedItem().equals("")) {
reqErr = true;
} else if (profile.equals(baseImg)) {
reqErr = true;
} else {
reqErr = false;
}
}

public void uploadImage() {


JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Select an Image");
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
try {
Image originalImage = ImageIO.read(file);
profile = originalImage.getScaledInstance(115, 115, Image.SCALE_SMOOTH);
repaint();
} catch (IOException e) {
e.printStackTrace();
}
}
}

public void initTxt() {


if (Err) {
snameTxt = "";
anoTxt = "";
dobTxt = "";
addTxt = "";
mnoTxt = "";
courseTxt = "";
} else {
snameTxt = txtSName.getText();
anoTxt = txtANo.getText();
dobTxt = txtDOB.getText();
addTxt = txtAdd.getText();
mnoTxt = txtMNo.getText();
courseTxt = ListCourse.getSelectedItem();
}
}

private void extractImage(int x, int y, int width, int height) {


viewID();
Err = CheckError();
if (Err)
return;

try {
Robot robot = new Robot();
Rectangle captureRect = new Rectangle(getX() + x, getY() + y, width, height);
BufferedImage image = robot.createScreenCapture(captureRect);

File outputFile = new File(txtSName.getText().replace(" ", "") + "_ID_CARD.png");


ImageIO.write(image, "png", outputFile);
showMessageBox("ID Card saved @ " + outputFile.getAbsolutePath());
} catch (AWTException | IOException e) {
e.printStackTrace();
}
}

private void showMessageBox(String message) {


JOptionPane.showMessageDialog(this, message, "Message Box",
JOptionPane.INFORMATION_MESSAGE);
}

public static void main(String[] args) {


Main app = new Main();
app.setVisible(true);
}
}
CHAPTER 4
RESULTS(SNAPSHOTS)
Executing the program:

Empty Form: Form with Invalid Data: Mobile Number


Form with Invalid Data: Birth Date Form with Valid Data:

Form with Invalid Data: Roll Number Printed ID Card:


CHAPTER 4
CONCLUSION

The primary aim of this project was to develop a simple ID card generator using Java that formats
user-provided data into a structured ID card. This objective has been successfully achieved. The
program enables the input of essential details, such as names, courses, and roll numbers, and effi-
ciently formats this information into a consistent, readable ID card layout.
Key findings from this project include the effective use of Java’s object-oriented capabilities to
handle user data and format it dynamically, ensuring that the output maintains a clear and organized
structure. The ID card generator is designed to be flexible and easily adaptable for different data
types and formatting requirements, making it applicable for various contexts where speed and sim-
plicity are prioritized.
The major outcome of this investigation is a functional tool that fulfills its role in environments re-
quiring rapid generation of formatted ID cards without security verification. Its significance lies in
its practicality for temporary or low-security scenarios, providing a fast, efficient solution for
presenting personal data in a clear, professional manner. The project contributes to the field by sim-
plifying ID card generation, offering a streamlined approach for scenarios where verification is not
a primary concern.
CHAPTER 6
REFERENCES
https://www.tutorialspoint.com/java
https://www.geeksforgeeks.org
https://www.w3schools.com/

You might also like