Project code: Mobile Security System
1)welcome.java
import java.awt.Color;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class welcome extends JFrame {
private static final long serialVersionUID = -6391524437237161585L;
private JPanel contentPane;
String name;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
welcome frame = new welcome(null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public welcome(String name) {
name=name.toUpperCase();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(300, 100, 350, 550);
contentPane = new JPanel();
contentPane.setBackground(Color.LIGHT_GRAY);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblWelcome = new JLabel("WEL_COME");
lblWelcome.setFont(new Font("Arial Black", Font.BOLD, 28));
lblWelcome.setBounds(67, 46, 201, 91);
contentPane.add(lblWelcome);
JLabel lblIn = new JLabel("IN");
lblIn.setHorizontalAlignment(SwingConstants.CENTER);
lblIn.setFont(new Font("Arial Black", Font.BOLD, 28));
lblIn.setBounds(67, 175, 201, 91);
contentPane.add(lblIn);
JLabel label = new JLabel(name);
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setFont(new Font("Arial Black", Font.BOLD, 28));
label.setBounds(67, 314, 201, 91);
contentPane.add(label);
JButton btnBack = new JButton("Back");
btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
apps ap=new apps();
ap.setVisible(true);
}
});
btnBack.setFont(new Font("Tahoma", Font.BOLD, 16));
btnBack.setBounds(108, 436, 119, 39);
contentPane.add(btnBack);
this.setResizable(false);
this.setLocation(600,100);
}
2)setpass.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.awt.BorderLayout;
import java.sql.*;
public class setpass extends JFrame implements ActionListener {
JButton submit,cancel;
Connection con;
Statement stm;
JLabel note,pass,pass1,sq1,sq2,sq1ans,sq2ans;
JPasswordField passt;
JTextField pass1t,sq1anst,sq2anst,hintt,sq1t,sq2t;
String name;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
setpass window = new setpass(null);
window.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public setpass(String name1) {
name=name1;
initialize();
}
private void initialize() {
setBounds(600, 100, 350, 550);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel container = new JPanel();
JScrollPane jsp = new JScrollPane(container);
container.setPreferredSize(new Dimension(350, 780));
container.setLayout(null);
note = new JLabel("*NOTE:All Fields are mandatory!!!");
note.setFont(new Font("Tahoma", Font.BOLD, 14));
note.setBounds(30, 10, 250, 20);
note.setForeground(Color.RED);
container.add(note);
pass = new JLabel("Enter the Password");
pass.setFont(new Font("Tahoma", Font.BOLD, 14));
pass.setBounds(100, 30, 150, 30);
container.add(pass);
passt=new JPasswordField();
passt.setBounds(110, 60, 120, 25);
container.add(passt);
pass1 = new JLabel("Re-enter the Password");
pass1.setFont(new Font("Tahoma", Font.BOLD, 14));
pass1.setBounds(90, 120, 180, 30);
container.add(pass1);
pass1t=new JTextField();
pass1t.setBounds(110, 150, 120, 25);
container.add(pass1t);
JLabel hint = new JLabel("Enter the Password hint");
hint.setFont(new Font("Tahoma", Font.BOLD, 14));
hint.setBounds(90, 210, 180, 30);
container.add(hint);
hintt=new JTextField("");
hintt.setBounds(110, 250, 120, 25);
container.add(hintt);
sq1 = new JLabel("Enter your Security Question1");
sq1.setFont(new Font("Tahoma", Font.BOLD, 14));
sq1.setBounds(80, 310, 230, 30);
container.add(sq1);
sq1t=new JTextField("");
sq1t.setBounds(110, 350, 120, 25);
container.add(sq1t);
sq2 = new JLabel("Enter your Security Question2");
sq2.setFont(new Font("Tahoma", Font.BOLD, 14));
sq2.setBounds(80, 410, 230, 30);
container.add(sq2);
sq2t=new JTextField("");
sq2t.setBounds(110, 450, 120, 25);
container.add(sq2t);
sq1ans = new JLabel("Enter the Security Q1 answer");
sq1ans.setFont(new Font("Tahoma", Font.BOLD, 14));
sq1ans.setBounds(70, 510, 230, 30);
container.add(sq1ans);
sq1anst=new JTextField("");
sq1anst.setBounds(110, 550, 120, 25);
container.add(sq1anst);
sq2ans = new JLabel("Enter the Security Q2 answer");
sq2ans.setFont(new Font("Tahoma", Font.BOLD, 14));
sq2ans.setBounds(70, 610, 230, 30);
container.add(sq2ans);
sq2anst=new JTextField("");
sq2anst.setBounds(110, 650, 120, 25);
container.add(sq2anst);
submit=new JButton("Submit");
submit.setBounds(50, 700, 100, 30);
container.add(submit);
submit.addActionListener(this);
cancel=new JButton("Cancel");
cancel.setBounds(180, 700, 100, 30);
container.add(cancel);
cancel.addActionListener(this);
getContentPane().add(jsp, BorderLayout.EAST);
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onkar?
useSSL=true","root","");
stm = con.createStatement();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex);
}
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==submit)
{
if(!
passt.getText().toString().contentEquals(pass1t.getText()))
{
JOptionPane.showMessageDialog(null,"Password
doesn't Match");
setpass st = new setpass(name);
st.setVisible(true);
}
else if(pass1t.getText().contentEquals("") ||
sq1anst.getText().contentEquals("") || sq1anst.getText().contentEquals("") ||
hintt.getText().contentEquals("") || sq1t.getText().contentEquals("") ||
sq2t.getText().contentEquals(""))
{
JOptionPane.showMessageDialog(null,"All fields are
Mandatory");
setpass st = new setpass(name);
st.setVisible(true);
}
else {
String a,b;
a=sq1anst.getText().toLowerCase();
b=sq2anst.getText().toLowerCase();
String str="insert into apps
values('"+name+"','"+pass1t.getText()+"','"+hintt.getText()+"','"+sq1t.getText()
+"','"+sq2t.getText()+"','"+a+"','"+b+"',1)";
try {
stm.executeUpdate(str);
} catch (SQLException e1) {
e1.printStackTrace();
}
JOptionPane.showMessageDialog(null,"Password set
Sucessfully");
securedapps frame = new securedapps();
frame.setVisible(true);
}
}
if(e.getSource()==cancel)
{
securedapps as=new securedapps();
as.setVisible(true);
}
}
}
3)securedapps.java
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.sql.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class securedapps extends JFrame implements ItemListener {
private JPanel contentPane;
JCheckBox
chckbxMusic,chckbxWhatsapp,chckbxFacebook,chckbxCandycrush,chckbxInsta
gram,chckbxVideos,chckbxMessanger,chckbxPubg,chckbxImages,chckbxSecurit
y;
Connection con;
Statement stm;
int f;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
securedapps frame = new securedapps();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
int check(String name) {
try {
String sql="select pass from apps where app='"+name+"'";
ResultSet rs=stm.executeQuery(sql);
if(rs.next())
return 0;
}
catch(Exception exp) {
}return 1;
}
public securedapps() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(600, 100, 350, 550);
contentPane = new JPanel();
contentPane.setBackground(Color.CYAN);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onkar?
useSSL=true","root","");
stm=con.createStatement();
}
catch(Exception ex){
JOptionPane.showMessageDialog(null,ex);
}
chckbxWhatsapp = new JCheckBox("Whatsapp");
chckbxWhatsapp = new JCheckBox("Whatsapp",true);
chckbxWhatsapp.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxWhatsapp.setBounds(30, 64, 127, 26);
f=check(chckbxWhatsapp.getText());
if(f==0)
chckbxWhatsapp.setSelected(true);
contentPane.add(chckbxWhatsapp);
chckbxWhatsapp.addItemListener(this);
chckbxFacebook = new JCheckBox("Facebook");
chckbxFacebook.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxFacebook.setBounds(198, 64, 127, 26);
f=check(chckbxFacebook.getText());
if(f==0)
chckbxFacebook.setSelected(true);
contentPane.add(chckbxFacebook);
chckbxFacebook.addItemListener(this);
chckbxCandycrush = new JCheckBox("CandyCrush");
chckbxCandycrush.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxCandycrush.setBounds(30, 130, 127, 26);
f=check(chckbxCandycrush.getText());
if(f==0)
chckbxCandycrush.setSelected(true);
contentPane.add(chckbxCandycrush);
chckbxCandycrush.addItemListener(this);
chckbxInstagram = new JCheckBox("Instagram");
chckbxInstagram.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxInstagram.setBounds(198, 130, 127, 26);
f=check(chckbxInstagram.getText());
if(f==0)
chckbxInstagram.setSelected(true);
contentPane.add(chckbxInstagram);
chckbxInstagram.addItemListener(this);
chckbxMessanger = new JCheckBox("Messanger");
chckbxMessanger.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxMessanger.setBounds(30, 199, 127, 26);
f=check(chckbxMessanger.getText());
if(f==0)
chckbxMessanger.setSelected(true);
contentPane.add(chckbxMessanger);
chckbxMessanger.addItemListener(this);
chckbxVideos = new JCheckBox("Videos");
chckbxVideos.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxVideos.setBounds(198, 199, 127, 26);
f=check(chckbxVideos.getText());
if(f==0)
chckbxVideos.setSelected(true);
contentPane.add(chckbxVideos);
chckbxVideos.addItemListener(this);
chckbxPubg = new JCheckBox("PUBG");
chckbxPubg.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxPubg.setBounds(30, 263, 127, 26);
f=check(chckbxPubg.getText());
if(f==0)
chckbxPubg.setSelected(true);
contentPane.add(chckbxPubg);
chckbxPubg.addItemListener(this);
chckbxMusic = new JCheckBox("Music");
chckbxMusic.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxMusic.setBounds(198, 263, 127, 26);
f=check(chckbxMusic.getText());
if(f==0)
chckbxMusic.setSelected(true);
contentPane.add(chckbxMusic);
chckbxMusic.addItemListener(this);
chckbxImages = new JCheckBox("Images");
chckbxImages.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxImages.setBounds(30, 324, 127, 26);
f=check(chckbxImages.getText());
if(f==0)
chckbxImages.setSelected(true);
contentPane.add(chckbxImages);
chckbxImages.addItemListener(this);
chckbxSecurity = new JCheckBox("Security");
chckbxSecurity.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxSecurity.setBounds(198, 324, 127, 26);
f=check(chckbxSecurity.getText());
if(f==0)
chckbxSecurity.setSelected(true);
contentPane.add(chckbxSecurity);
chckbxSecurity.addItemListener(this);
JLabel lblNewLabel = new JLabel("*Note: Selected Checkedboxes
are ");
lblNewLabel.setForeground(Color.RED);
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
lblNewLabel.setBounds(27, 415, 293, 40);
contentPane.add(lblNewLabel);
JLabel lblSecuredWithPasswords = new JLabel(" Secured with
Passwords");
lblSecuredWithPasswords.setForeground(Color.RED);
lblSecuredWithPasswords.setFont(new Font("Tahoma",
Font.BOLD, 16));
lblSecuredWithPasswords.setBounds(82, 450, 210, 40);
contentPane.add(lblSecuredWithPasswords);
JButton btnBack = new JButton("Back");
btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
apps frame = new apps();
frame.setVisible(true);
}
});
btnBack.setFont(new Font("Tahoma", Font.BOLD, 14));
btnBack.setBounds(122, 384, 101, 31);
contentPane.add(btnBack);
JCheckBox chckbxLockScreen = new JCheckBox("Lock Screen");
chckbxLockScreen.setFont(new Font("Tahoma", Font.BOLD, 16));
chckbxLockScreen.setBounds(111, 16, 127, 26);
f=check(chckbxLockScreen.getText());
if(f==0)
chckbxLockScreen.setSelected(true);
contentPane.add(chckbxLockScreen);
chckbxLockScreen.addItemListener(this);
this.setResizable(false);
}
public void itemStateChanged(ItemEvent e) {
if(e.getStateChange()==ItemEvent.SELECTED)
{
JCheckBox o=(JCheckBox)e.getSource();
setpass window = new setpass(o.getText());
window.setVisible(true);
}
else
{
JCheckBox o=(JCheckBox)e.getSource();
remove frame = new remove(o.getText());
frame.setVisible(true);
}
}
}
4)reset.java
import java.awt.Color;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.sql.*;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
@SuppressWarnings("serial")
public class reset extends JFrame {
private JPanel contentPane;
private JTextField textField;
private JTextField textField_1;
Connection con;
String q1,q2,temp;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
reset frame = new reset(null,null,null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public reset(String q1,String q2,String temp) {
this.q1=q1;this.q2=q2;this.temp=temp;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(630, 100, 300, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onkar?
useSSL=true","root","");
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex);
}
JLabel lblAnswerTheQuesions = new JLabel("Answer the
Quesions");
lblAnswerTheQuesions.setFont(new Font("Tahoma", Font.BOLD,
18));
lblAnswerTheQuesions.setBounds(51, 10, 207, 35);
contentPane.add(lblAnswerTheQuesions);
JLabel lblNewLabel = new JLabel(q1);
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
lblNewLabel.setBackground(Color.WHITE);
lblNewLabel.setBounds(10, 55, 276, 23);
contentPane.add(lblNewLabel);
textField = new JTextField();
textField.setBounds(71, 88, 140, 23);
contentPane.add(textField);
textField.setColumns(10);
JLabel lblQuestion = new JLabel(q2);
lblQuestion.setFont(new Font("Tahoma", Font.BOLD, 16));
lblQuestion.setHorizontalAlignment(SwingConstants.CENTER);
lblQuestion.setBounds(10, 136, 276, 23);
contentPane.add(lblQuestion);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_1.setBounds(71, 169, 140, 23);
contentPane.add(textField_1);
JButton btnSubmit = new JButton("OK");
btnSubmit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Statement stm = con.createStatement();
String sql="select * from apps where
app='"+temp+"'";
ResultSet rs=stm.executeQuery(sql);
rs.next();
String ans1=rs.getString(6);
String ans2=rs.getString(7);
String
check1=textField.getText().toString().toLowerCase();
String
check2=textField_1.getText().toString().toLowerCase();
if(ans1.contentEquals(check1) &&
ans2.contentEquals(check2))
{
passreset psrt=new
passreset(temp);
psrt.setVisible(true);
}
else
JOptionPane.showMessageDialog(null,"Wrong Answers");
}
catch(Exception exp) {
JOptionPane.showMessageDialog(null,exp);
}
}
});
btnSubmit.setFont(new Font("Tahoma", Font.BOLD, 14));
btnSubmit.setBounds(37, 217, 85, 35);
contentPane.add(btnSubmit);
JButton btnCancel = new JButton("Cancel");
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
password pass=new password(temp);
pass.setVisible(true);
}
});
btnCancel.setFont(new Font("Tahoma", Font.BOLD, 14));
btnCancel.setBounds(159, 217, 85, 35);
contentPane.add(btnCancel);
this.setResizable(false);
}
}
5)remove.java
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
public class remove extends JFrame {
private JPanel contentPane;
private JPasswordField passwordField;
Connection con;
Statement stm;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
remove frame = new remove(null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public remove( String apname) {
super("Remove Password");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(600, 100, 350, 270);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onkar?
useSSL=true","root","");
stm=con.createStatement();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex);
}
JLabel lblEnterYourPassword = new JLabel("Enter Your
Password");
lblEnterYourPassword.setFont(new Font("Tahoma", Font.BOLD,
16));
lblEnterYourPassword.setBounds(88, 32, 192, 34);
contentPane.add(lblEnterYourPassword);
passwordField = new JPasswordField();
passwordField.setBounds(97, 88, 146, 28);
contentPane.add(passwordField);
JButton btnRemove = new JButton("Remove");
btnRemove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String str="delete from apps where app='"+apname+"'";
try {
stm.executeUpdate(str);
JOptionPane.showMessageDialog(null,apname+"'s
Password removed successfully");
securedapps frame = new securedapps();
frame.setVisible(true);
} catch (SQLException e1) {
e1.printStackTrace();
}
}
});
btnRemove.setFont(new Font("Tahoma", Font.BOLD, 14));
btnRemove.setBounds(40, 163, 102, 28);
contentPane.add(btnRemove);
JButton btnCancel = new JButton("Cancel");
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
securedapps as=new securedapps();
as.setVisible(true);
}
});
btnCancel.setFont(new Font("Tahoma", Font.BOLD, 14));
btnCancel.setBounds(195, 163, 85, 28);
contentPane.add(btnCancel);
}
}
6)remove.java
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
public class remove extends JFrame {
private JPanel contentPane;
private JPasswordField passwordField;
Connection con;
Statement stm;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
remove frame = new remove(null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public remove( String apname) {
super("Remove Password");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(600, 100, 350, 270);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onkar?
useSSL=true","root","");
stm=con.createStatement();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex);
}
JLabel lblEnterYourPassword = new JLabel("Enter Your
Password");
lblEnterYourPassword.setFont(new Font("Tahoma", Font.BOLD,
16));
lblEnterYourPassword.setBounds(88, 32, 192, 34);
contentPane.add(lblEnterYourPassword);
passwordField = new JPasswordField();
passwordField.setBounds(97, 88, 146, 28);
contentPane.add(passwordField);
JButton btnRemove = new JButton("Remove");
btnRemove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String str="delete from apps where app='"+apname+"'";
try {
stm.executeUpdate(str);
JOptionPane.showMessageDialog(null,apname+"'s
Password removed successfully");
securedapps frame = new securedapps();
frame.setVisible(true);
} catch (SQLException e1) {
e1.printStackTrace();
}
}
});
btnRemove.setFont(new Font("Tahoma", Font.BOLD, 14));
btnRemove.setBounds(40, 163, 102, 28);
contentPane.add(btnRemove);
JButton btnCancel = new JButton("Cancel");
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
securedapps as=new securedapps();
as.setVisible(true);
}
});
btnCancel.setFont(new Font("Tahoma", Font.BOLD, 14));
btnCancel.setBounds(195, 163, 85, 28);
contentPane.add(btnCancel);
}
}
7)password.java
import java.awt.EventQueue;
import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
@SuppressWarnings("serial")
public class password extends JFrame {
private JPanel contentPane;
private JPasswordField passwordField;
String str;
Connection con;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
password frame = new password(null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public password(String str1) {
str=str1;
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(630, 100, 300, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
this.setResizable(false);
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onkar?
useSSL=true","root","");
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex);
}
Date date = new Date();
String strDateFormat = "hh:mm a";
DateFormat dateFormat = new SimpleDateFormat(strDateFormat);
DateFormat dateFormat1 = new SimpleDateFormat("hhmm");
String formattedDate= dateFormat.format(date);
String formattedDate1= dateFormat1.format(date);
JButton btnNewButton = new JButton("Submit");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Statement stm = con.createStatement();
String sql="select pass from apps where
app='"+str+"'";
ResultSet rs=stm.executeQuery(sql);
rs.next();
String pass=rs.getString(1)+formattedDate1;
String
check=passwordField.getText().toString();
String st="Lock Screen";
if(pass.contentEquals(check))
{
if(!str.contentEquals("Security") && !
str.contentEquals("Lock Screen")) {
welcome wlc=new welcome(str);
wlc.setVisible(true);
}
else
{
if(str.contentEquals("Security")) {
securedapps sa=new
securedapps();
sa.setVisible(true);
}
else {
apps ap=new apps();
ap.setVisible(true);
}
}
}
else {
JOptionPane.showMessageDialog(null,"Wrong Password Try again!!!");
}
}
catch(Exception exp) {
JOptionPane.showMessageDialog(null,exp);
}
}});
btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 14));
btnNewButton.setBounds(24, 136, 115, 29);
contentPane.add(btnNewButton);
JButton btnHint = new JButton("Hint");
btnHint.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Statement stm = con.createStatement();
String sql="select hint from apps where
app='"+str+"'";
ResultSet rs=stm.executeQuery(sql);
rs.next();
JOptionPane.showMessageDialog(null,rs.getString(1));
}
catch(Exception exp) {
JOptionPane.showMessageDialog(null,exp);
}
}
});
btnHint.setFont(new Font("Tahoma", Font.BOLD, 14));
btnHint.setBounds(24, 195, 115, 29);
contentPane.add(btnHint);
passwordField = new JPasswordField();
passwordField.setToolTipText("Enter Password");
passwordField.setBounds(60, 80, 170, 30);
contentPane.add(passwordField);
JButton btnReset = new JButton("Reset");
btnReset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Statement stm = con.createStatement();
String sql="select * from apps where
app='"+str+"'";
ResultSet rs=stm.executeQuery(sql);
rs.next();
String q1=rs.getString(4);
String q2=rs.getString(5);
reset rset=new reset(q1,q2,str);
rset.setVisible(true);
}
catch(Exception exp) {
JOptionPane.showMessageDialog(null,exp);
}
}
});
btnReset.setFont(new Font("Tahoma", Font.BOLD, 14));
btnReset.setBounds(170, 194, 104, 31);
contentPane.add(btnReset);
JButton btnCancel = new JButton("Back");
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(!str.contentEquals("Lock Screen"))
{
apps app=new apps();
app.setVisible(true);
}
else
{
login log=new login();
log.setVisible(true);
}
}
});
btnCancel.setFont(new Font("Tahoma", Font.BOLD, 14));
btnCancel.setBounds(170, 136, 104, 29);
contentPane.add(btnCancel);
JLabel lblEnterThePassword = new JLabel("Enter the Password");
lblEnterThePassword.setHorizontalAlignment(SwingConstants.CENTER);
lblEnterThePassword.setFont(new Font("Tahoma", Font.BOLD,
18));
lblEnterThePassword.setBounds(44, 44, 217, 23);
contentPane.add(lblEnterThePassword);
JLabel label = new JLabel(formattedDate);
label.setFont(new Font("Tahoma", Font.BOLD, 14));
label.setBounds(186, 10, 88, 24);
contentPane.add(label);
}
}
8)passreset.java
import java.awt.EventQueue;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
@SuppressWarnings("serial")
public class passreset extends JFrame {
private JPanel contentPane;
String pass;
Connection con;
private JPasswordField passwordField;
private JTextField textField;
private JTextField textField_1;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
passreset frame = new passreset(null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public passreset(String pass) {
this.pass=pass;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(630, 100, 300, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onkar?
useSSL=true","root","");
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex);
}
JLabel lblEnterTheNew = new JLabel("Enter the new Password");
lblEnterTheNew.setFont(new Font("Tahoma", Font.BOLD, 16));
lblEnterTheNew.setBounds(38, 10, 205, 31);
contentPane.add(lblEnterTheNew);
JLabel lblConfirmPassword = new JLabel("Confirm Password");
lblConfirmPassword.setFont(new Font("Tahoma", Font.BOLD,
16));
lblConfirmPassword.setBounds(52, 78, 205, 31);
contentPane.add(lblConfirmPassword);
passwordField = new JPasswordField();
passwordField.setBounds(78, 38, 129, 30);
contentPane.add(passwordField);
textField = new JTextField();
textField.setBounds(78, 107, 129, 30);
contentPane.add(textField);
textField.setColumns(10);
JLabel lblNewPasswordHint = new JLabel("New Password Hint");
lblNewPasswordHint.setFont(new Font("Tahoma", Font.BOLD,
16));
lblNewPasswordHint.setBounds(52, 147, 205, 31);
contentPane.add(lblNewPasswordHint);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_1.setBounds(78, 174, 129, 30);
contentPane.add(textField_1);
JButton btnReset = new JButton("Reset");
btnReset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Statement stm = con.createStatement();
String sql="update apps set
pass='"+textField.getText()+"' where app='"+pass+"'";
String sql2="update apps set
hint='"+textField_1.getText()+"' where app='"+pass+"'";
stm.executeUpdate(sql);
stm.executeUpdate(sql2);
JOptionPane.showMessageDialog(null,"Password Reset Sucessfully");
apps ap=new apps();
ap.setVisible(true);
}
catch(Exception exp) {
JOptionPane.showMessageDialog(null,exp);
}
}
});
btnReset.setFont(new Font("Tahoma", Font.BOLD, 14));
btnReset.setBounds(31, 220, 92, 33);
contentPane.add(btnReset);
JButton btnCancel = new JButton("Cancel");
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
password rst=new password(pass);
rst.setVisible(true);
}
});
btnCancel.setFont(new Font("Tahoma", Font.BOLD, 14));
btnCancel.setBounds(165, 220, 92, 33);
contentPane.add(btnCancel);
}
}
9)login.java
import java.awt.EventQueue;
import java.sql.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.awt.event.ActionEvent;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
import javax.swing.JPasswordField;
public class login extends JFrame {
public JPanel contentPane;
Connection con;
JLabel time1;
public static void main(String[] args)throws Exception {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
login frame = new login();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public login() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(300, 100, 350, 550);
contentPane = new JPanel();
contentPane.setBackground(Color.CYAN);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
this.setResizable(false);
this.setLocation(600,100);
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onkar?
useSSL=true","root","");
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex);
}
JButton admin = new JButton("UNLock");
admin.setIcon(new ImageIcon("C:\\Users\\dell\\Downloads\\
lock.jpg"));
admin.setHorizontalAlignment(SwingConstants.RIGHT);
admin.setFont(new Font("Tahoma", Font.BOLD, 18));
Date date = new Date();
String strDateFormat = "hh:mm a";
DateFormat dateFormat = new SimpleDateFormat(strDateFormat);
DateFormat dateFormat1 = new SimpleDateFormat("hhmm");
String formattedDate= dateFormat.format(date);
String formattedDate1= dateFormat1.format(date);
time1 = new JLabel(formattedDate);
time1.setForeground(Color.GRAY);
time1.setFont(new Font("Tahoma", Font.BOLD, 18));
time1.setBounds(197, 23, 129, 41);
contentPane.add(time1);
admin.addActionListener(new ActionListener() {
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e) {
Statement stm;
if(e.getSource()== admin)
{
apps ap=new apps();
int f=ap.check("Lock Screen");
if(f==1)
ap.setVisible(true);
else {
password pass=new password("Lock Screen");
pass.setVisible(true);
}
}
}
});
admin.setBounds(96, 365, 129, 54);
contentPane.add(admin);
}
}
10)apps.java
import java.sql.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener;
import java.text.*;
import java.util.Date;
import java.awt.event.ActionEvent;
import java.awt.*;
public class apps extends JFrame implements ActionListener {
private JPanel contentPane;
Connection con;
Statement stm;
int flag;
JButton btnMusic;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
apps frame = new apps();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
int check(String name)
{
try {
String sql="select pass from apps where app='"+name+"'";
ResultSet rs=stm.executeQuery(sql);
if(rs.next())
return 0;
}
catch(Exception exp) {
}
return 1;
}
public apps() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(600, 100, 350, 550);
contentPane = new JPanel();
contentPane.setBackground(Color.WHITE);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(null);
setContentPane(contentPane);
try {
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/onkar?
useSSL=true","root","");
stm = con.createStatement();
catch(Exception ex)
{
JOptionPane.showMessageDialog(null,ex);
}
Date date = new Date();
String strDateFormat = "hh:mm a";
DateFormat dateFormat = new SimpleDateFormat(strDateFormat);
String formattedDate= dateFormat.format(date);
JPanel panel = new JPanel();
panel.setBackground(Color.CYAN);
panel.setBounds(10, 37, 326, 466);
contentPane.add(panel);
panel.setLayout(null);
JButton btnWhatsapp = new JButton("Whatsapp");
btnWhatsapp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnWhatsapp.getText());
if(flag==0)
{
password pass=new
password(btnWhatsapp.getText());
pass.setVisible(true);
}
else {
welcome wlc=new
welcome(btnWhatsapp.getText());
wlc.setVisible(true);
}
}
});
btnWhatsapp.setForeground(Color.BLACK);
btnWhatsapp.setFont(new Font("Tahoma", Font.BOLD, 14));
btnWhatsapp.setBounds(22, 34, 120, 45);
panel.add(btnWhatsapp);
JButton btnFacebook = new JButton("Facebook");
btnFacebook.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnFacebook.getText());
if(flag==0)
{
password pass=new
password(btnFacebook.getText());
pass.setVisible(true);
}
else {
welcome wlc=new
welcome(btnFacebook.getText());
wlc.setVisible(true);
}
}
});
btnFacebook.setFont(new Font("Tahoma", Font.BOLD, 14));
btnFacebook.setBounds(172, 34, 120, 44);
panel.add(btnFacebook);
JButton btnSecurity = new JButton("Security");
btnSecurity.setFont(new Font("Tahoma", Font.BOLD, 14));
btnSecurity.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnSecurity.getText());
if(flag==0)
{
password pass=new
password(btnSecurity.getText());
pass.setVisible(true);
}
else {
securedapps sa=new securedapps();
sa.setVisible(true);
}
}
});
btnSecurity.setBounds(22, 130, 120, 45);
panel.add(btnSecurity);
JButton btnInsatgram = new JButton("Instagram");
btnInsatgram.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnInsatgram.getText());
if(flag==0)
{
password pass=new
password(btnInsatgram.getText());
pass.setVisible(true);
}
else {
welcome wlc=new
welcome(btnInsatgram.getText());
wlc.setVisible(true);
}
}
});
btnInsatgram.setFont(new Font("Tahoma", Font.BOLD, 14));
btnInsatgram.setBounds(172, 130, 120, 45);
panel.add(btnInsatgram);
JButton btnMessanger = new JButton("Messanger");
btnMessanger.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnMessanger.getText());
if(flag==0)
{
password pass=new
password(btnMessanger.getText());
pass.setVisible(true);
}
else {
welcome wlc=new
welcome(btnMessanger.getText());
wlc.setVisible(true);
}
}
});
btnMessanger.setFont(new Font("Tahoma", Font.BOLD, 14));
btnMessanger.setBounds(22, 220, 120, 45);
panel.add(btnMessanger);
JButton btnVideoPlayer = new JButton("Videos");
btnVideoPlayer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnVideoPlayer.getText());
if(flag==0)
{
password pass=new
password(btnVideoPlayer.getText());
pass.setVisible(true);
}
else {
welcome wlc=new
welcome(btnVideoPlayer.getText());
wlc.setVisible(true);
}
}
});
btnVideoPlayer.setFont(new Font("Tahoma", Font.BOLD, 14));
btnVideoPlayer.setBounds(172, 220, 120, 45);
panel.add(btnVideoPlayer);
JButton btnImages = new JButton("Images");
btnImages.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnImages.getText());
if(flag==0)
{
password pass=new
password(btnImages.getText());
pass.setVisible(true);
}
else {
welcome wlc=new
welcome(btnImages.getText());
wlc.setVisible(true);
}
}
});
btnImages.setFont(new Font("Tahoma", Font.BOLD, 14));
btnImages.setBounds(22, 315, 120, 45);
panel.add(btnImages);
JButton btnPubg = new JButton("PUBG");
btnPubg.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnPubg.getText());
if(flag==0)
{
password pass=new
password(btnPubg.getText());
pass.setVisible(true);
}
else {
welcome wlc=new
welcome(btnPubg.getText());
wlc.setVisible(true);
}
}
});
btnPubg.setFont(new Font("Tahoma", Font.BOLD, 14));
btnPubg.setBounds(172, 315, 120, 45);
panel.add(btnPubg);
JButton btnCandyCrush = new JButton("CandyCrush");
btnCandyCrush.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnCandyCrush.getText());
if(flag==0)
{
password pass=new
password(btnCandyCrush.getText());
pass.setVisible(true);
}
else {
welcome wlc=new
welcome(btnCandyCrush.getText());
wlc.setVisible(true);
}
}
});
btnCandyCrush.setFont(new Font("Tahoma", Font.BOLD, 14));
btnCandyCrush.setBounds(22, 407, 120, 45);
panel.add(btnCandyCrush);
btnMusic = new JButton("Music");
btnMusic.addActionListener(this);
/* btnMusic.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=check(btnMusic.getText());
if(flag==0)
{
password pass=new
password(btnMusic.getText());
pass.setVisible(true);
}
else {
welcome wlc=new
welcome(btnMusic.getText());
wlc.setVisible(true);
}
}
});*/
btnMusic.setFont(new Font("Tahoma", Font.BOLD, 14));
btnMusic.setBounds(172, 407, 120, 45);
panel.add(btnMusic);
JLabel lblNewLabel = new JLabel(formattedDate);
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
lblNewLabel.setBounds(214, 10, 94, 24);
contentPane.add(lblNewLabel);
this.setResizable(false);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==btnMusic)
{
JButton o=(JButton)e.getSource();
System.out.print(o.getText());
flag=check(o.getText());
if(flag==0)
{
password pass=new password(o.getText());
pass.setVisible(true);
}
else {
welcome wlc=new welcome(o.getText());
wlc.setVisible(true);
}
}
}
}