├── README.md ├── owner.java ├── MicroDVR2.0.exe ├── sobel filtering.exe ├── alsensor.ino ├── alcohol_with_beep.ino ├── alcohol.ino ├── sketch_may09al.ino ├── connection.txt ├── owner.txt ├── driver dwos left eye.txt ├── login.java ├── serialconnection.txt ├── adminhome.java └── admin.java /README.md: -------------------------------------------------------------------------------- 1 | # DRIVER-DROWSINESS-DETECTION 2 | -------------------------------------------------------------------------------- /owner.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varma-loyal-2004/DRIVER-DROWSINESS-DETECTION/HEAD/owner.java -------------------------------------------------------------------------------- /MicroDVR2.0.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varma-loyal-2004/DRIVER-DROWSINESS-DETECTION/HEAD/MicroDVR2.0.exe -------------------------------------------------------------------------------- /sobel filtering.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Varma-loyal-2004/DRIVER-DROWSINESS-DETECTION/HEAD/sobel filtering.exe -------------------------------------------------------------------------------- /alsensor.ino: -------------------------------------------------------------------------------- 1 | int alsensor = 8; 2 | int value=0; 3 | int thresholdValue=600; 4 | void setup() { 5 | // put your setup code here, to run once: 6 | digitalWrite(alsensor, INPUT); 7 | 8 | } 9 | 10 | void loop() { 11 | // put your main code here, to run repeatedly: 12 | 13 | 14 | if(thresholdValue > value) 15 | { 16 | 17 | Serial.print("al"); 18 | 19 | } 20 | else 21 | { 22 | Serial.print(" not al"); 23 | 24 | } 25 | //delay(3000); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /alcohol_with_beep.ino: -------------------------------------------------------------------------------- 1 | 2 | const int gasPin = A0; 3 | 4 | void setup () 5 | 6 | { 7 | Serial.begin(9600); //Initialize serial port - 9600 bps 8 | } 9 | 10 | 11 | 12 | void loop () { 13 | 14 | 15 | 16 | if (gasPin > 650){ 17 | analogWrite (speakerPin, 650); 18 | delay (500); 19 | Serial.println("HIGH"); 20 | delay (10); 21 | } else 22 | 23 | { 24 | Serial.println("LOW"); 25 | delay (500); 26 | } 27 | 28 | //Serial.println(analogRead(gasPin)); 29 | delay(500); // Print value every 1 sec. 30 | } 31 | -------------------------------------------------------------------------------- /alcohol.ino: -------------------------------------------------------------------------------- 1 | 2 | int ALC = A5; 3 | // Your threshold value 4 | int smsensorThres = 130; 5 | 6 | void setup() { 7 | pinMode(ALC, INPUT); 8 | Serial.begin(9600); 9 | } 10 | 11 | void loop() { 12 | int analogSensor = analogRead(ALC); 13 | 14 | //Serial.print("Pin A5: "); 15 | Serial.println(analogSensor); 16 | // Checks if it has reached the threshold value 17 | if (analogSensor > smsensorThres) 18 | { 19 | Serial.println("ALCOHOL DETECTED"); 20 | } 21 | else 22 | { 23 | Serial.println("NOT DETECTED"); 24 | } 25 | delay(100); 26 | } 27 | -------------------------------------------------------------------------------- /sketch_may09al.ino: -------------------------------------------------------------------------------- 1 | int Input = A5; 2 | int SensorVal = 0; 3 | int Check = 0; 4 | void setup() { 5 | Serial.begin(9600); 6 | pinMode(Input, INPUT); 7 | 8 | // Serial. println("Design by www.TheEngineeringProjects.com"); 9 | //Serial.println(); 10 | } 11 | 12 | void loop() { 13 | 14 | SensorVal = analogRead(Input); 15 | // Serial.println(SensorVal); 16 | if((SensorVal > 170) && (Check == 1)) 17 | { 18 | Serial.println("a"); 19 | Check = 0; 20 | } 21 | 22 | if((SensorVal < 170) && (Check == 0)) 23 | { 24 | //Serial.println("All Clear . . ."); 25 | Check = 1; 26 | } 27 | //Serial.println(SensorVal); 28 | delay(500); 29 | } 30 | -------------------------------------------------------------------------------- /connection.txt: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Data.SqlClient; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Windows.Forms; 10 | 11 | namespace WebcamSecurity 12 | { 13 | public partial class Admin : Form 14 | { 15 | public Admin() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void Admin_Load(object sender, EventArgs e) 21 | { 22 | String strCon = "Data Source=DESKTOP-DEL5R27;Initial Catalog=WebCam;Integrated Security=True"; 23 | var select = "SELECT * FROM data"; 24 | var c = new SqlConnection(strCon); 25 | var dataAdapter = new SqlDataAdapter(select, c); 26 | 27 | var commandBuilder = new SqlCommandBuilder(dataAdapter); 28 | var ds = new DataSet(); 29 | dataAdapter.Fill(ds); 30 | dataGridView1.ReadOnly = true; 31 | dataGridView1.DataSource = ds.Tables[0]; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /owner.txt: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Data.SqlClient; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Windows.Forms; 10 | 11 | namespace WebcamSecurity 12 | { 13 | public partial class OwnerDashBoard : Form 14 | { 15 | public OwnerDashBoard() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void button1_Click(object sender, EventArgs e) 21 | { 22 | String strCon = "Data Source=DESKTOP-DEL5R27;Initial Catalog=WebCam;Integrated Security=True"; 23 | var select = "SELECT * FROM data where Username='"+textBox1.Text+"'"; 24 | var c = new SqlConnection(strCon); 25 | var dataAdapter = new SqlDataAdapter(select, c); 26 | 27 | var commandBuilder = new SqlCommandBuilder(dataAdapter); 28 | var ds = new DataSet(); 29 | dataAdapter.Fill(ds); 30 | dataGridView1.ReadOnly = true; 31 | dataGridView1.DataSource = ds.Tables[0]; 32 | } 33 | 34 | private void OwnerDashBoard_Load(object sender, EventArgs e) 35 | { 36 | 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /driver dwos left eye.txt: -------------------------------------------------------------------------------- 1 | public Bitmap left_eye(Bitmap b) 2 | { 3 | 4 | b = black_white(b); 5 | int i, j, max, x, h, w, y; 6 | max = 0; 7 | x = 0; 8 | 9 | h = b.Height; 10 | w = b.Width; 11 | y = h - 1; 12 | for (i = 2; i < 2 * h / 3; i++) 13 | { 14 | for (j = 0; j < w; j++) 15 | { 16 | if (b.GetPixel(j, i).R == 0 && b.GetPixel(j, i).G == 0 && b.GetPixel(j, i).B == 0) 17 | break; 18 | } 19 | if (j == w) 20 | j = w - 1; 21 | if (max <= j && j != 0) 22 | { 23 | max = j; 24 | x = i; 25 | } 26 | if (i >= h / 2 && j < w / 3) 27 | break; 28 | } 29 | for (i = h - 1; i >= h / 2; i--) 30 | { 31 | int count = 0; 32 | for (j = w / 4; j <= 3 * w / 4; j++) 33 | if (b.GetPixel(j, i).R == 0 && b.GetPixel(j, i).G == 0 && b.GetPixel(j, i).B == 0) 34 | count++; 35 | if (count * 2 >= w / 2) 36 | break; 37 | } 38 | if (i != h - 1) 39 | y = i + 1; 40 | 41 | int le_1 = 0, ri_1 = w - 1, ttt = 0; 42 | ttt = 0; 43 | for (j = 0; j < w; j++) 44 | { 45 | for (i = 0; i < h; i++) 46 | if (b.GetPixel(j, i).R == 0 && b.GetPixel(j, i).G == 0 && b.GetPixel(j, i).B == 0) 47 | { 48 | ttt = 1; 49 | break; 50 | } 51 | if (ttt == 1) 52 | { 53 | le_1 = j; 54 | break; 55 | } 56 | } 57 | ttt = 0; 58 | for (j = w - 1; j >= 0; j--) 59 | { 60 | for (i = 0; i < h; i++) 61 | if (b.GetPixel(j, i).R == 0 && b.GetPixel(j, i).G == 0 && b.GetPixel(j, i).B == 0) 62 | { 63 | ttt = 1; 64 | break; 65 | } 66 | if (ttt == 1) 67 | { 68 | ri_1 = j; 69 | break; 70 | } 71 | } 72 | 73 | ttt = 0; 74 | for (i = x; i < y; i++) 75 | { 76 | for (j = w / 4; j < w - w / 4; j++) 77 | if (b.GetPixel(j, i).R == 0 && b.GetPixel(j, i).G == 0 && b.GetPixel(j, i).B == 0) 78 | { 79 | ttt = 1; 80 | break; 81 | } 82 | if (ttt == 1) 83 | { 84 | x = i; 85 | break; 86 | } 87 | } 88 | ttt = 0; 89 | for (i = y; i >= x; i--) 90 | 91 | { 92 | for (j = w / 4; j < w - w / 4; j++) 93 | if (b.GetPixel(j, i).R == 0 && b.GetPixel(j, i).G == 0 && b.GetPixel(j, i).B == 0) 94 | { 95 | ttt = 1; 96 | break; 97 | } 98 | if (ttt == 1) 99 | { 100 | y = i; 101 | break; 102 | } 103 | } 104 | 105 | b = new Bitmap(pictureBox3.Image); 106 | Bitmap BB = new Bitmap(w - le_1, h - x); 107 | 108 | for (i = le_1; i < w; i++) 109 | for (j = x; j < h; j++) 110 | BB.SetPixel(i - le_1, j - x, b.GetPixel(i, j)); 111 | 112 | return BB; 113 | 114 | } 115 | -------------------------------------------------------------------------------- /login.java: -------------------------------------------------------------------------------- 1 | package proj1; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JPanel; 7 | import javax.swing.JLabel; 8 | import javax.swing.JOptionPane; 9 | 10 | import java.awt.Color; 11 | import javax.swing.JTextField; 12 | import javax.swing.JButton; 13 | import javax.swing.ImageIcon; 14 | import java.awt.Font; 15 | import java.awt.event.ActionListener; 16 | import java.sql.Connection; 17 | import java.sql.DriverManager; 18 | import java.sql.PreparedStatement; 19 | import java.sql.ResultSet; 20 | import java.sql.Statement; 21 | import java.awt.event.ActionEvent; 22 | import javax.swing.JPasswordField; 23 | 24 | public class proj2 { 25 | 26 | JFrame frame; 27 | protected Object loginframe; 28 | private JPasswordField passwordField; 29 | private JTextField textField; 30 | private JPasswordField passwordField_1; 31 | 32 | /** 33 | * Launch the application. 34 | */ 35 | public static void main(String[] args) { 36 | EventQueue.invokeLater(new Runnable() { 37 | public void run() { 38 | try { 39 | proj2 window = new proj2(); 40 | window.frame.setVisible(true); 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | } 45 | }); 46 | } 47 | 48 | /** 49 | * Create the application. 50 | */ 51 | public proj2() { 52 | initialize(); 53 | } 54 | 55 | /** 56 | * Initialize the contents of the frame. 57 | */ 58 | private void initialize() { 59 | frame = new JFrame(); 60 | frame.setBounds(100, 100, 1422, 788); 61 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 62 | frame.getContentPane().setLayout(null); 63 | 64 | JPanel panel_1 = new JPanel(); 65 | panel_1.setBounds(0, 0, 1370, 749); 66 | frame.getContentPane().add(panel_1); 67 | panel_1.setLayout(null); 68 | 69 | JLabel errorup = new JLabel(""); 70 | errorup.setForeground(Color.RED); 71 | errorup.setBounds(862, 396, 211, 14); 72 | panel_1.add(errorup); 73 | 74 | JLabel lblLoginHere = new JLabel("LOGIN HERE"); 75 | lblLoginHere.setForeground(Color.WHITE); 76 | lblLoginHere.setFont(new Font("Calibri", Font.BOLD, 30)); 77 | lblLoginHere.setBounds(928, 181, 173, 47); 78 | panel_1.add(lblLoginHere); 79 | 80 | JLabel lblUsername = new JLabel("USERNAME"); 81 | lblUsername.setForeground(Color.WHITE); 82 | lblUsername.setFont(new Font("Calibri", Font.BOLD, 14)); 83 | lblUsername.setBounds(858, 237, 145, 32); 84 | panel_1.add(lblUsername); 85 | 86 | textField = new JTextField(); 87 | textField.setBounds(858, 270, 215, 32); 88 | panel_1.add(textField); 89 | textField.setColumns(10); 90 | 91 | JLabel lblPassword = new JLabel("PASSWORD"); 92 | lblPassword.setForeground(Color.WHITE); 93 | lblPassword.setFont(new Font("Calibri", Font.BOLD, 14)); 94 | lblPassword.setBounds(858, 313, 93, 14); 95 | panel_1.add(lblPassword); 96 | 97 | passwordField_1 = new JPasswordField(); 98 | passwordField_1.setBounds(858, 338, 215, 32); 99 | panel_1.add(passwordField_1); 100 | 101 | JButton btnLogin = new JButton("LOGIN"); 102 | btnLogin.setForeground(Color.WHITE); 103 | btnLogin.addActionListener(new ActionListener() { 104 | public void actionPerformed(ActionEvent e) { 105 | 106 | String un=textField.getText(); 107 | String psw=passwordField_1.getText(); 108 | 109 | try 110 | { 111 | Class.forName("com.mysql.jdbc.Driver"); 112 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 113 | 114 | ResultSet rs = null; 115 | 116 | PreparedStatement ps = con.prepareStatement("select * from admin where username='"+un+"' and password='"+psw+"'"); 117 | rs = ps.executeQuery(); 118 | 119 | if(rs.next()) { 120 | admin window = new admin(); 121 | window.frame.setVisible(true); 122 | proj2.this.frame.setVisible(false); 123 | } 124 | 125 | else { 126 | try { 127 | Class.forName("com.mysql.jdbc.Driver"); 128 | Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 129 | 130 | ResultSet rss = null; 131 | 132 | PreparedStatement pss = conn.prepareStatement("select * from owner_details where user='"+un+"' and passw='"+psw+"'"); 133 | rss = pss.executeQuery(); 134 | 135 | if(rss.next()) { 136 | owner window = new owner(); 137 | window.frame.setVisible(true); 138 | proj2.this.frame.setVisible(false); 139 | } 140 | 141 | /*else { 142 | JOptionPane.showMessageDialog(null, "enter the valid username and password"); 143 | }*/ 144 | 145 | if(un!="+un+" || psw!="+psw+") 146 | { 147 | textField.setEditable(true); 148 | passwordField_1.setEditable(true); 149 | errorup.setText("*Invalid Username or Password"); 150 | 151 | } 152 | } 153 | catch(Exception e1) 154 | { 155 | e1.printStackTrace(); 156 | } 157 | } 158 | } 159 | 160 | catch(Exception e1) 161 | { 162 | e1.printStackTrace(); 163 | } 164 | 165 | textField.setText(""); 166 | passwordField_1.setText(""); 167 | Refresh(); 168 | 169 | } 170 | 171 | private void Refresh() { 172 | // TODO Auto-generated method stub 173 | 174 | } 175 | 176 | 177 | }); 178 | btnLogin.setBackground(Color.DARK_GRAY); 179 | btnLogin.setFont(new Font("Calibri", Font.BOLD, 16)); 180 | btnLogin.setBounds(910, 421, 108, 53); 181 | panel_1.add(btnLogin); 182 | 183 | JLabel lblNewLabel_1 = new JLabel("New label"); 184 | lblNewLabel_1.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\Capture6.JPG")); 185 | lblNewLabel_1.setBounds(878, 149, 48, 96); 186 | panel_1.add(lblNewLabel_1); 187 | 188 | JLabel image = new JLabel("image"); 189 | image.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\background-front-page-cropped.jpg")); 190 | image.setBounds(0, 5, 1370, 738); 191 | panel_1.add(image); 192 | 193 | 194 | 195 | 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /serialconnection.txt: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using WebcamSecurity.Serial; 10 | using System.IO; 11 | using System.Speech.Synthesis; 12 | 13 | 14 | using System.Web; 15 | 16 | using System.IO; 17 | 18 | using System.Net; 19 | using System.Web.UI; 20 | using System.Web.UI.WebControls; 21 | using System.Data.SqlClient; 22 | 23 | namespace WebcamSecurity 24 | { 25 | public partial class Serialnew : Form 26 | { 27 | SerialPortManager _spManager; 28 | public static string user; 29 | public Serialnew() 30 | { 31 | InitializeComponent(); 32 | 33 | UserInitialization(); 34 | } 35 | 36 | 37 | private void UserInitialization() 38 | { 39 | _spManager = new SerialPortManager(); 40 | SerialSettings mySerialSettings = _spManager.CurrentSerialSettings; 41 | serialSettingsBindingSource.DataSource = mySerialSettings; 42 | portNameComboBox.DataSource = mySerialSettings.PortNameCollection; 43 | baudRateComboBox.DataSource = mySerialSettings.BaudRateCollection; 44 | dataBitsComboBox.DataSource = mySerialSettings.DataBitsCollection; 45 | parityComboBox.DataSource = Enum.GetValues(typeof(System.IO.Ports.Parity)); 46 | stopBitsComboBox.DataSource = Enum.GetValues(typeof(System.IO.Ports.StopBits)); 47 | 48 | _spManager.NewSerialDataRecieved += new EventHandler(_spManager_NewSerialDataRecieved); 49 | this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing); 50 | } 51 | 52 | 53 | private void MainForm_FormClosing(object sender, FormClosingEventArgs e) 54 | { 55 | _spManager.Dispose(); 56 | } 57 | 58 | void _spManager_NewSerialDataRecieved(object sender, SerialDataEventArgs e) 59 | { 60 | String strCon = "Data Source=DESKTOP-DEL5R27;Initial Catalog=WebCam;Integrated Security=True"; 61 | user = Loginpage.user; 62 | if (this.InvokeRequired) 63 | { 64 | // Using this.Invoke causes deadlock when closing serial port, and BeginInvoke is good practice anyway. 65 | this.BeginInvoke(new EventHandler(_spManager_NewSerialDataRecieved), new object[] { sender, e }); 66 | return; 67 | } 68 | 69 | int maxTextLength = 1000; // maximum text length in text box 70 | if (tbData.TextLength > maxTextLength) 71 | tbData.Text = tbData.Text.Remove(0, tbData.TextLength - maxTextLength); 72 | 73 | // This application is connected to a GPS sending ASCCI characters, so data is converted to text 74 | 75 | string str = Encoding.ASCII.GetString(e.Data); 76 | 77 | //byte[] ba = Encoding.Default.GetBytes(str); 78 | 79 | //var hexString = BitConverter.ToString(ba); 80 | 81 | 82 | if (str.Contains("ys") == true) 83 | { 84 | if (Application.OpenForms.OfType().Count() == 0) 85 | { 86 | MainForm a = new MainForm(); 87 | a.Show(); 88 | } 89 | 90 | SpeechSynthesizer voice = new SpeechSynthesizer(); 91 | voice.Volume = 100; 92 | voice.Rate = -1; 93 | voice.SelectVoiceByHints(VoiceGender.Female); 94 | 95 | for (int z = 0; z <= 1; z++) 96 | { 97 | voice.SpeakAsync("Baby is crying"); 98 | } 99 | } 100 | if(str.Contains("f") == true) 101 | { 102 | SpeechSynthesizer voice = new SpeechSynthesizer(); 103 | voice.Volume = 100; 104 | voice.Rate = -1; 105 | voice.SelectVoiceByHints(VoiceGender.Female); 106 | 107 | for (int z = 0; z <= 1; z++) 108 | { 109 | voice.SpeakAsync("Fire alert"); 110 | } 111 | } 112 | if (str.Contains("sm") == true) 113 | { 114 | SpeechSynthesizer voice = new SpeechSynthesizer(); 115 | voice.Volume = 100; 116 | voice.Rate = -1; 117 | voice.SelectVoiceByHints(VoiceGender.Female); 118 | 119 | for (int z = 0; z <= 1; z++) 120 | { 121 | voice.SpeakAsync("Smoke detected"); 122 | } 123 | } 124 | 125 | if (str.Contains("a") == true) 126 | { 127 | SqlConnection con = new SqlConnection(strCon); 128 | con.Open(); 129 | //string query = "select * from data"; 130 | //SqlCommand cmd = new SqlCommand(query, con); 131 | 132 | //SqlDataReader dataReader = cmd.ExecuteReader(); 133 | 134 | //while (dataReader.Read()) 135 | //{ 136 | // MessageBox.Show(dataReader["User"].ToString()); 137 | //} 138 | 139 | string query = "INSERT INTO data (UserName,Message)VALUES('"+Loginpage.user+"', 'Drunk driver detected')"; 140 | 141 | SqlCommand myCommand = new SqlCommand(query, con); 142 | 143 | myCommand.ExecuteNonQuery(); 144 | //dataReader.Close(); 145 | 146 | con.Close(); 147 | 148 | SpeechSynthesizer voice = new SpeechSynthesizer(); 149 | voice.Volume = 100; 150 | voice.Rate = -1; 151 | voice.SelectVoiceByHints(VoiceGender.Female); 152 | 153 | for (int z = 0; z <= 1; z++) 154 | { 155 | voice.SpeakAsync("Alcoholic driver detected"); 156 | } 157 | } 158 | 159 | 160 | tbData.AppendText(str); 161 | tbData.ScrollToCaret(); 162 | 163 | } 164 | 165 | public static string GetResponse(string sURL) 166 | { 167 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sURL); 168 | request.MaximumAutomaticRedirections = 4; 169 | request.Credentials = CredentialCache.DefaultCredentials; 170 | try 171 | { 172 | HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 173 | Stream receiveStream = response.GetResponseStream(); 174 | StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8); 175 | string sResponse = readStream.ReadToEnd(); 176 | response.Close(); 177 | readStream.Close(); 178 | return "SMS Sent Successfully"; 179 | } 180 | catch 181 | { 182 | return "SMS NOT SENT"; 183 | } 184 | 185 | } 186 | 187 | // Handles the "Start Listening"-buttom click event 188 | private void btnStart_Click(object sender, EventArgs e) 189 | { 190 | _spManager.StartListening(); 191 | } 192 | 193 | // Handles the "Stop Listening"-buttom click event 194 | private void btnStop_Click(object sender, EventArgs e) 195 | { 196 | _spManager.StopListening(); 197 | } 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /adminhome.java: -------------------------------------------------------------------------------- 1 | package proj1; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JPanel; 7 | import javax.swing.JButton; 8 | import javax.swing.JCheckBox; 9 | 10 | import java.awt.CardLayout; 11 | import javax.swing.JLabel; 12 | import javax.swing.JOptionPane; 13 | import javax.swing.JTextField; 14 | import javax.swing.UIManager; 15 | import javax.swing.border.LineBorder; 16 | import javax.swing.table.DefaultTableModel; 17 | import javax.swing.table.TableCellRenderer; 18 | 19 | import com.mysql.jdbc.ResultSet; 20 | 21 | import javax.swing.JRadioButton; 22 | import javax.swing.JScrollPane; 23 | import javax.swing.JTable; 24 | import javax.swing.JTextArea; 25 | import java.awt.Color; 26 | import java.awt.Component; 27 | import java.awt.Font; 28 | import java.awt.Frame; 29 | 30 | import javax.swing.ButtonGroup; 31 | import javax.swing.DefaultCellEditor; 32 | import javax.swing.ImageIcon; 33 | import java.awt.event.ActionListener; 34 | import java.sql.Connection; 35 | import java.sql.DriverManager; 36 | import java.sql.PreparedStatement; 37 | import java.sql.Statement; 38 | import java.awt.event.ActionEvent; 39 | import java.awt.event.KeyAdapter; 40 | import java.awt.event.KeyEvent; 41 | 42 | 43 | public class admin1 { 44 | 45 | JFrame frame; 46 | private JTextField textField; 47 | private JTextField textField_2; 48 | private JTextField textField_1; 49 | private JTextField textField_3; 50 | private JTextField textField_4; 51 | private JTextField textField_5; 52 | private JTextField textField_6; 53 | private JTextField textField_7; 54 | private JTextField textField_8; 55 | private JTextField textField_9; 56 | /*private JPasswordField passwordField;*/ 57 | private JTextField textField_10; 58 | private JTable table; 59 | 60 | /** 61 | * Launch the application. 62 | */ 63 | public static void main(String[] args) { 64 | EventQueue.invokeLater(new Runnable() { 65 | public void run() { 66 | try { 67 | admin window = new admin(); 68 | window.frame.setVisible(true); 69 | } catch (Exception e) { 70 | e.printStackTrace(); 71 | } 72 | } 73 | }); 74 | } 75 | 76 | /** 77 | * Create the application. 78 | */ 79 | public admin1() { 80 | initialize(); 81 | } 82 | 83 | /** 84 | * Initialize the contents of the frame. 85 | */ 86 | private void initialize() { 87 | 88 | ButtonGroup G1; 89 | G1 = new ButtonGroup(); 90 | 91 | frame = new JFrame(); 92 | frame.setBounds(100, 100, 1413, 788); 93 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 94 | frame.getContentPane().setLayout(null); 95 | 96 | JPanel panel = new JPanel(); 97 | panel.setBounds(-11, 69, 174, 675); 98 | frame.getContentPane().add(panel); 99 | panel.setLayout(null); 100 | 101 | 102 | 103 | JPanel panel_1 = new JPanel(); 104 | panel_1.setBounds(0, 0, 1370, 49); 105 | frame.getContentPane().add(panel_1); 106 | panel_1.setLayout(null); 107 | 108 | 109 | 110 | 111 | JPanel panel_2 = new JPanel(); 112 | panel_2.setBounds(161, 68, 1209, 681); 113 | frame.getContentPane().add(panel_2); 114 | panel_2.setLayout(new CardLayout(0, 0)); 115 | 116 | JPanel panel_5 = new JPanel(); 117 | panel_2.add(panel_5, "name_612598371549080"); 118 | panel_5.setLayout(null); 119 | 120 | JLabel label_16 = new JLabel("to change the world for good"); 121 | label_16.setForeground(Color.WHITE); 122 | label_16.setFont(new Font("Bookman Old Style", Font.PLAIN, 25)); 123 | label_16.setBounds(333, 497, 406, 39); 124 | panel_5.add(label_16); 125 | 126 | JLabel label_15 = new JLabel("Driving innovation"); 127 | label_15.setForeground(Color.WHITE); 128 | label_15.setFont(new Font("Bookman Old Style", Font.BOLD, 35)); 129 | label_15.setBounds(333, 430, 359, 56); 130 | panel_5.add(label_15); 131 | 132 | JLabel label_14 = new JLabel("WELCOME"); 133 | label_14.setForeground(Color.WHITE); 134 | label_14.setFont(new Font("Bookman Old Style", Font.BOLD, 70)); 135 | label_14.setBounds(244, 213, 415, 85); 136 | panel_5.add(label_14); 137 | 138 | JLabel lblNewLabel_11 = new JLabel(""); 139 | lblNewLabel_11.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\2017-12_CarHop_Website_1600x850_88944735-1600x850.jpg")); 140 | lblNewLabel_11.setBounds(0, 0, 1219, 696); 141 | panel_5.add(lblNewLabel_11); 142 | 143 | JPanel panel_3 = new JPanel(); 144 | panel_2.add(panel_3, "name_577813858504149"); 145 | panel_3.setLayout(null); 146 | 147 | 148 | 149 | JButton btnSubmit = new JButton("SUBMIT"); 150 | 151 | btnSubmit.setForeground(Color.WHITE); 152 | btnSubmit.setBackground(Color.GRAY); 153 | btnSubmit.setBounds(675, 549, 119, 47); 154 | panel_3.add(btnSubmit); 155 | 156 | 157 | 158 | JLabel errorad = new JLabel(""); 159 | errorad.setForeground(Color.RED); 160 | errorad.setBounds(674, 316, 120, 14); 161 | panel_3.add(errorad); 162 | 163 | 164 | 165 | JLabel errorname = new JLabel(""); 166 | errorname.setForeground(Color.RED); 167 | errorname.setBounds(674, 164, 190, 14); 168 | panel_3.add(errorname); 169 | 170 | JLabel errordob = new JLabel(""); 171 | errordob.setForeground(Color.RED); 172 | errordob.setBounds(674, 262, 158, 14); 173 | panel_3.add(errordob); 174 | 175 | JLabel errorph = new JLabel(""); 176 | errorph.setForeground(Color.RED); 177 | errorph.setBounds(674, 370, 135, 14); 178 | panel_3.add(errorph); 179 | 180 | JLabel errorli = new JLabel(""); 181 | errorli.setForeground(Color.RED); 182 | errorli.setBounds(672, 427, 137, 14); 183 | panel_3.add(errorli); 184 | 185 | 186 | 187 | textField_10 = new JTextField(); 188 | textField_10.setBounds(674, 500, 171, 25); 189 | panel_3.add(textField_10); 190 | textField_10.setColumns(10); 191 | 192 | JLabel lblOwnerRegistration = new JLabel("OWNER REGISTRATION"); 193 | lblOwnerRegistration.setFont(new Font("Verdana", Font.BOLD | Font.ITALIC, 20)); 194 | lblOwnerRegistration.setForeground(Color.CYAN); 195 | lblOwnerRegistration.setBounds(466, 67, 289, 33); 196 | panel_3.add(lblOwnerRegistration); 197 | 198 | JLabel lblName = new JLabel("NAME"); 199 | lblName.setFont(new Font("Verdana", Font.BOLD, 12)); 200 | lblName.setBounds(373, 133, 79, 21); 201 | panel_3.add(lblName); 202 | 203 | textField = new JTextField(); 204 | textField.setBounds(675, 128, 170, 25); 205 | panel_3.add(textField); 206 | textField.setColumns(10); 207 | 208 | JLabel lblNewLabel = new JLabel("GENDER"); 209 | lblNewLabel.setFont(new Font("Verdana", Font.BOLD, 12)); 210 | lblNewLabel.setBounds(373, 188, 79, 14); 211 | panel_3.add(lblNewLabel); 212 | 213 | JLabel lblDob = new JLabel("DOB"); 214 | lblDob.setFont(new Font("Verdana", Font.BOLD, 12)); 215 | lblDob.setBounds(373, 238, 46, 14); 216 | panel_3.add(lblDob); 217 | 218 | textField_2 = new JTextField(); 219 | textField_2.setBounds(674, 230, 171, 25); 220 | panel_3.add(textField_2); 221 | textField_2.setColumns(10); 222 | 223 | JRadioButton rdbtnMale = new JRadioButton("MALE"); 224 | rdbtnMale.setBounds(675, 185, 79, 23); 225 | panel_3.add(rdbtnMale); 226 | 227 | JRadioButton rdbtnFemale = new JRadioButton("FEMALE"); 228 | rdbtnFemale.setBounds(756, 185, 89, 23); 229 | panel_3.add(rdbtnFemale); 230 | 231 | 232 | G1.add(rdbtnMale); 233 | G1.add(rdbtnFemale); 234 | 235 | 236 | JLabel lblAddress = new JLabel("ADDRESS"); 237 | lblAddress.setFont(new Font("Verdana", Font.BOLD, 12)); 238 | lblAddress.setBounds(373, 287, 79, 14); 239 | panel_3.add(lblAddress); 240 | 241 | JLabel lblPhoneNumber = new JLabel("PHONE NUMBER"); 242 | lblPhoneNumber.setFont(new Font("Verdana", Font.BOLD, 12)); 243 | lblPhoneNumber.setBounds(373, 344, 109, 14); 244 | panel_3.add(lblPhoneNumber); 245 | 246 | JTextArea textArea = new JTextArea(); 247 | textArea.setBounds(675, 272, 170, 41); 248 | panel_3.add(textArea); 249 | 250 | textField_1 = new JTextField(); 251 | textField_1.addKeyListener(new KeyAdapter() { 252 | @Override 253 | public void keyPressed(java.awt.event.KeyEvent evt) { 254 | String Phn=textField_1.getText(); 255 | int length=Phn.length(); 256 | char c=evt.getKeyChar(); 257 | if(evt.getKeyChar()>='0' && evt.getKeyChar()<='9') 258 | { 259 | 260 | if(length<10) 261 | { 262 | textField_1.setEditable(true); 263 | errorph.setText("*enter 10 digits:"); 264 | } 265 | 266 | 267 | else 268 | { 269 | textField_1.setEditable(false); 270 | errorph.setText(""); 271 | } 272 | } 273 | else 274 | { 275 | if(evt.getExtendedKeyCode()==KeyEvent.VK_BACK_SPACE||evt.getExtendedKeyCode()==KeyEvent.VK_DELETE) 276 | { 277 | textField_1.setEditable(true); 278 | } 279 | 280 | else { 281 | textField_1.setEditable(false); 282 | } 283 | } 284 | } 285 | 286 | }); 287 | textField_1.setBounds(675, 336, 170, 23); 288 | panel_3.add(textField_1); 289 | textField_1.setColumns(10); 290 | 291 | JLabel lblLicenseNumber = new JLabel("LICENSE NUMBER"); 292 | lblLicenseNumber.setFont(new Font("Verdana", Font.BOLD, 12)); 293 | lblLicenseNumber.setBounds(373, 403, 129, 14); 294 | panel_3.add(lblLicenseNumber); 295 | 296 | textField_3 = new JTextField(); 297 | textField_3.setBounds(674, 395, 171, 22); 298 | panel_3.add(textField_3); 299 | textField_3.setColumns(10); 300 | 301 | 302 | 303 | JLabel label = new JLabel(":"); 304 | label.setFont(new Font("Tahoma", Font.BOLD, 12)); 305 | label.setBounds(545, 136, 46, 14); 306 | panel_3.add(label); 307 | 308 | JLabel label_1 = new JLabel(":"); 309 | label_1.setFont(new Font("Tahoma", Font.BOLD, 12)); 310 | label_1.setBounds(545, 188, 46, 14); 311 | panel_3.add(label_1); 312 | 313 | JLabel label_2 = new JLabel(":"); 314 | label_2.setFont(new Font("Tahoma", Font.BOLD, 12)); 315 | label_2.setBounds(545, 238, 46, 14); 316 | panel_3.add(label_2); 317 | 318 | JLabel label_3 = new JLabel(":"); 319 | label_3.setFont(new Font("Tahoma", Font.BOLD, 12)); 320 | label_3.setBounds(545, 287, 46, 14); 321 | panel_3.add(label_3); 322 | 323 | JLabel label_4 = new JLabel(":"); 324 | label_4.setFont(new Font("Tahoma", Font.BOLD, 12)); 325 | label_4.setBounds(545, 344, 46, 14); 326 | panel_3.add(label_4); 327 | 328 | JLabel label_5 = new JLabel(":"); 329 | label_5.setFont(new Font("Tahoma", Font.BOLD, 12)); 330 | label_5.setBounds(545, 403, 46, 14); 331 | panel_3.add(label_5); 332 | 333 | JLabel lblNewLabel_9 = new JLabel("New label"); 334 | lblNewLabel_9.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\1920x1080-white-solid-color-background.jpg")); 335 | lblNewLabel_9.setBounds(292, 58, 620, 59); 336 | panel_3.add(lblNewLabel_9); 337 | 338 | JLabel lblUsername = new JLabel("USERNAME"); 339 | lblUsername.setFont(new Font("Verdana", Font.BOLD, 12)); 340 | lblUsername.setBounds(373, 456, 109, 14); 341 | panel_3.add(lblUsername); 342 | 343 | JLabel lblNewLabel_13 = new JLabel(":"); 344 | lblNewLabel_13.setFont(new Font("Tahoma", Font.BOLD, 12)); 345 | lblNewLabel_13.setBounds(545, 456, 46, 14); 346 | panel_3.add(lblNewLabel_13); 347 | 348 | textField_9 = new JTextField(); 349 | textField_9.setBounds(674, 448, 171, 22); 350 | panel_3.add(textField_9); 351 | textField_9.setColumns(10); 352 | 353 | JLabel lblPassword = new JLabel("PASSWORD"); 354 | lblPassword.setFont(new Font("Verdana", Font.BOLD, 12)); 355 | lblPassword.setBounds(373, 508, 109, 14); 356 | panel_3.add(lblPassword); 357 | 358 | JLabel label_13 = new JLabel(":"); 359 | label_13.setFont(new Font("Tahoma", Font.BOLD, 12)); 360 | label_13.setBounds(545, 508, 46, 14); 361 | panel_3.add(label_13); 362 | 363 | JLabel lblNewLabel_1 = new JLabel("New label"); 364 | lblNewLabel_1.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\wallpapers-plain-colors-26.jpg")); 365 | lblNewLabel_1.setBounds(292, 114, 620, 527); 366 | panel_3.add(lblNewLabel_1); 367 | 368 | JLabel lblNewLabel_10 = new JLabel("New label"); 369 | lblNewLabel_10.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\bg7.jpg")); 370 | lblNewLabel_10.setBounds(0, 0, 1178, 701); 371 | panel_3.add(lblNewLabel_10); 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | JPanel panel_4 = new JPanel(); 380 | panel_2.add(panel_4, "name_579286929612941"); 381 | panel_4.setLayout(null); 382 | 383 | JLabel errornumb = new JLabel(""); 384 | errornumb.setForeground(Color.RED); 385 | errornumb.setBounds(637, 180, 151, 14); 386 | panel_4.add(errornumb); 387 | 388 | JLabel erroroname = new JLabel(""); 389 | erroroname.setForeground(Color.RED); 390 | erroroname.setBounds(637, 246, 169, 14); 391 | panel_4.add(erroroname); 392 | 393 | JLabel errormod = new JLabel(""); 394 | errormod.setForeground(Color.RED); 395 | errormod.setBounds(637, 348, 151, 14); 396 | panel_4.add(errormod); 397 | 398 | 399 | JLabel lblVehicleRegistration = new JLabel("VEHICLE REGISTRATION"); 400 | lblVehicleRegistration.setForeground(Color.CYAN); 401 | lblVehicleRegistration.setFont(new Font("Verdana", Font.BOLD | Font.ITALIC, 20)); 402 | lblVehicleRegistration.setBounds(455, 90, 288, 24); 403 | panel_4.add(lblVehicleRegistration); 404 | 405 | JLabel label_6 = new JLabel("VEHICLE NUMBER"); 406 | label_6.setForeground(Color.BLACK); 407 | label_6.setFont(new Font("Verdana", Font.BOLD, 12)); 408 | label_6.setBounds(315, 155, 151, 20); 409 | panel_4.add(label_6); 410 | 411 | textField_4 = new JTextField(); 412 | textField_4.setColumns(10); 413 | textField_4.setBounds(637, 151, 175, 24); 414 | panel_4.add(textField_4); 415 | 416 | JLabel lblOwnerName = new JLabel("OWNER NAME"); 417 | lblOwnerName.setForeground(Color.BLACK); 418 | lblOwnerName.setFont(new Font("Verdana", Font.BOLD, 12)); 419 | lblOwnerName.setBounds(315, 207, 110, 24); 420 | panel_4.add(lblOwnerName); 421 | 422 | textField_5 = new JTextField(); 423 | textField_5.setBounds(637, 205, 175, 24); 424 | panel_4.add(textField_5); 425 | textField_5.setColumns(10); 426 | 427 | JLabel lblNewLabel_2 = new JLabel("TYPE OF VEHICLE"); 428 | lblNewLabel_2.setForeground(Color.BLACK); 429 | lblNewLabel_2.setFont(new Font("Verdana", Font.BOLD, 12)); 430 | lblNewLabel_2.setBounds(316, 268, 130, 19); 431 | panel_4.add(lblNewLabel_2); 432 | 433 | JRadioButton radioButton = new JRadioButton("Car"); 434 | radioButton.setFont(new Font("Verdana", Font.PLAIN, 12)); 435 | radioButton.setBounds(637, 265, 61, 24); 436 | panel_4.add(radioButton); 437 | 438 | JRadioButton radioButton_1 = new JRadioButton("Van"); 439 | radioButton_1.setFont(new Font("Verdana", Font.PLAIN, 12)); 440 | radioButton_1.setBounds(710, 265, 55, 24); 441 | panel_4.add(radioButton_1); 442 | 443 | JRadioButton radioButton_2 = new JRadioButton("Bus"); 444 | radioButton_2.setFont(new Font("Verdana", Font.PLAIN, 12)); 445 | radioButton_2.setBounds(778, 266, 61, 23); 446 | panel_4.add(radioButton_2); 447 | 448 | JRadioButton rdbtnOther = new JRadioButton("Other"); 449 | rdbtnOther.setFont(new Font("Verdana", Font.PLAIN, 12)); 450 | rdbtnOther.setBounds(852, 265, 73, 24); 451 | panel_4.add(rdbtnOther); 452 | 453 | G1.add(radioButton); 454 | G1.add(radioButton_1); 455 | G1.add(radioButton_2); 456 | G1.add(rdbtnOther); 457 | 458 | 459 | 460 | JLabel lblModel = new JLabel("MODEL"); 461 | lblModel.setForeground(Color.BLACK); 462 | lblModel.setFont(new Font("Verdana", Font.BOLD, 12)); 463 | lblModel.setBounds(316, 324, 73, 14); 464 | panel_4.add(lblModel); 465 | 466 | textField_6 = new JTextField(); 467 | textField_6.setBounds(637, 317, 175, 24); 468 | panel_4.add(textField_6); 469 | textField_6.setColumns(10); 470 | 471 | JLabel lblColor = new JLabel("COLOR"); 472 | lblColor.setForeground(Color.BLACK); 473 | lblColor.setFont(new Font("Verdana", Font.BOLD, 12)); 474 | lblColor.setBounds(315, 380, 74, 14); 475 | panel_4.add(lblColor); 476 | 477 | textField_7 = new JTextField(); 478 | textField_7.setBounds(637, 373, 175, 24); 479 | panel_4.add(textField_7); 480 | textField_7.setColumns(10); 481 | 482 | JLabel lblYearOfManufacture = new JLabel("YEAR OF MANUFACTURE"); 483 | lblYearOfManufacture.setForeground(Color.BLACK); 484 | lblYearOfManufacture.setFont(new Font("Verdana", Font.BOLD, 12)); 485 | lblYearOfManufacture.setBounds(315, 432, 169, 24); 486 | panel_4.add(lblYearOfManufacture); 487 | 488 | textField_8 = new JTextField(); 489 | textField_8.setBounds(637, 430, 175, 24); 490 | panel_4.add(textField_8); 491 | textField_8.setColumns(10); 492 | 493 | JButton btnSubmit_1 = new JButton("SUBMIT"); 494 | btnSubmit_1.addActionListener(new ActionListener() { 495 | public void actionPerformed(ActionEvent arg0) { 496 | 497 | String vnum=textField_4.getText(); 498 | String oname=textField_5.getText(); 499 | String mod=textField_6.getText(); 500 | String clr=textField_7.getText(); 501 | String yr=textField_8.getText(); 502 | String typ = " "; 503 | 504 | // If condition to check if jRadioButton2 is selected. 505 | if (radioButton.isSelected()) { 506 | 507 | typ= "Car"; 508 | } 509 | 510 | else if (radioButton_1.isSelected()) { 511 | 512 | typ = "Van"; 513 | } 514 | else if (radioButton_2.isSelected()) { 515 | 516 | typ= "Bus"; 517 | } 518 | 519 | else if (rdbtnOther.isSelected()) { 520 | 521 | typ= "Other"; 522 | } 523 | else { 524 | typ="no selected"; 525 | } 526 | if(textField_4.getText().isEmpty()||textField_5.getText().isEmpty()||textField_6.getText().isEmpty()||textField_7.getText().isEmpty()||textField_8.getText().isEmpty()) 527 | { 528 | if(textField_4.getText().isEmpty()) { 529 | errornumb.setText("*enter valid number"); 530 | } 531 | if(textField_5.getText().isEmpty()) { 532 | erroroname.setText("*enter valid name"); 533 | } 534 | if(textField_6.getText().isEmpty()) { 535 | errormod.setText("*enter model name"); 536 | } 537 | 538 | } 539 | else 540 | { 541 | 542 | 543 | try 544 | { 545 | Class.forName("com.mysql.jdbc.Driver"); 546 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 547 | Statement st=con.createStatement(); 548 | int k=st.executeUpdate("insert into vehicle(v_no,own_name,type,model,color,year) values('"+vnum+"','"+oname+"','"+typ+"','"+mod+"','"+clr+"','"+yr+"')"); 549 | 550 | 551 | JOptionPane.showMessageDialog(null,"REGISTRATION SUCCESSFUL"); 552 | } 553 | catch(Exception e) 554 | { 555 | System.out.println(e); 556 | e.printStackTrace(); 557 | } 558 | } 559 | textField_4.setText(""); 560 | textField_5.setText(""); 561 | textField_6.setText(""); 562 | textField_7.setText(""); 563 | textField_8.setText(""); 564 | 565 | G1.clearSelection(); 566 | 567 | Refresh(); 568 | 569 | } 570 | 571 | private void Refresh() { 572 | // TODO Auto-generated method stub 573 | 574 | } 575 | }); 576 | btnSubmit_1.setForeground(Color.WHITE); 577 | btnSubmit_1.setBackground(Color.GRAY); 578 | btnSubmit_1.setBounds(637, 491, 122, 51); 579 | panel_4.add(btnSubmit_1); 580 | 581 | JLabel label_7 = new JLabel(":"); 582 | label_7.setForeground(Color.WHITE); 583 | label_7.setFont(new Font("Tahoma", Font.BOLD, 12)); 584 | label_7.setBounds(545, 158, 46, 14); 585 | panel_4.add(label_7); 586 | 587 | JLabel label_8 = new JLabel(":"); 588 | label_8.setForeground(Color.WHITE); 589 | label_8.setFont(new Font("Tahoma", Font.BOLD, 12)); 590 | label_8.setBounds(545, 212, 46, 14); 591 | panel_4.add(label_8); 592 | 593 | JLabel label_9 = new JLabel(":"); 594 | label_9.setForeground(Color.WHITE); 595 | label_9.setFont(new Font("Tahoma", Font.BOLD, 12)); 596 | label_9.setBounds(545, 270, 46, 14); 597 | panel_4.add(label_9); 598 | 599 | JLabel label_10 = new JLabel(":"); 600 | label_10.setForeground(Color.WHITE); 601 | label_10.setFont(new Font("Tahoma", Font.BOLD, 12)); 602 | label_10.setBounds(545, 324, 46, 14); 603 | panel_4.add(label_10); 604 | 605 | JLabel label_11 = new JLabel(":"); 606 | label_11.setForeground(Color.WHITE); 607 | label_11.setFont(new Font("Tahoma", Font.BOLD, 12)); 608 | label_11.setBounds(545, 389, 46, 14); 609 | panel_4.add(label_11); 610 | 611 | JLabel label_12 = new JLabel(":"); 612 | label_12.setForeground(Color.WHITE); 613 | label_12.setFont(new Font("Tahoma", Font.BOLD, 12)); 614 | label_12.setBounds(545, 437, 46, 14); 615 | panel_4.add(label_12); 616 | 617 | JLabel lblNewLabel_3 = new JLabel("New label"); 618 | lblNewLabel_3.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\wallpapers-plain-colors-26.jpg")); 619 | lblNewLabel_3.setBounds(254, 125, 689, 447); 620 | panel_4.add(lblNewLabel_3); 621 | 622 | JLabel lblNewLabel_7 = new JLabel("New label"); 623 | lblNewLabel_7.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\1920x1080-white-solid-color-background.jpg")); 624 | lblNewLabel_7.setBackground(Color.GREEN); 625 | lblNewLabel_7.setBounds(254, 72, 689, 56); 626 | panel_4.add(lblNewLabel_7); 627 | 628 | JLabel lblNewLabel_8 = new JLabel("New label"); 629 | lblNewLabel_8.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\o-TYPING-facebook.jpg")); 630 | lblNewLabel_8.setBounds(0, 0, 1209, 696); 631 | panel_4.add(lblNewLabel_8); 632 | 633 | 634 | 635 | 636 | JPanel panel_6 = new JPanel(); 637 | panel_2.add(panel_6, "name_585182201879387"); 638 | panel_6.setLayout(null); 639 | 640 | JScrollPane scrollPane_1 = new JScrollPane(); 641 | scrollPane_1.setBounds(0, 0, 1209, 681); 642 | scrollPane_1.setFont(new Font("Times New Roman", Font.BOLD, 17)); 643 | scrollPane_1.setForeground(Color.WHITE); 644 | scrollPane_1.setBackground(Color.DARK_GRAY); 645 | 646 | panel_6.add(scrollPane_1); 647 | 648 | 649 | 650 | 651 | 652 | 653 | JPanel panel_7 = new JPanel(); 654 | panel_2.add(panel_7, "name_616164740729907"); 655 | panel_7.setLayout(null); 656 | 657 | 658 | 659 | JScrollPane scrollPane_2 = new JScrollPane(); 660 | scrollPane_2.setFont(new Font("Times New Roman", Font.BOLD, 17)); 661 | scrollPane_2.setForeground(Color.WHITE); 662 | scrollPane_2.setBackground(Color.DARK_GRAY); 663 | scrollPane_2.setBounds(0,0,1209,780); 664 | 665 | panel_7.add(scrollPane_2); 666 | 667 | table = new JTable(); 668 | table.setBounds(0, 0, 1, 1); 669 | panel_7.add(table); 670 | 671 | 672 | 673 | 674 | 675 | 676 | JButton btnNewButton = new JButton("ADD OWNER"); 677 | btnNewButton.setForeground(Color.WHITE); 678 | btnNewButton.setBackground(Color.BLUE); 679 | btnNewButton.addActionListener(new ActionListener() { 680 | public void actionPerformed(ActionEvent arg0) { 681 | 682 | panel_2.removeAll(); 683 | panel_2.add(panel_3); 684 | panel_2.repaint(); 685 | panel_2.revalidate(); 686 | 687 | } 688 | }); 689 | 690 | JLabel lblNewLabel_14 = new JLabel("Dashboard"); 691 | lblNewLabel_14.setFont(new Font("Bookman Old Style", Font.BOLD, 21)); 692 | lblNewLabel_14.setForeground(Color.BLUE); 693 | lblNewLabel_14.setBounds(30, 139, 121, 38); 694 | panel.add(lblNewLabel_14); 695 | btnNewButton.setBounds(25, 211, 126, 70); 696 | panel.add(btnNewButton); 697 | 698 | JButton btnNewButton_2 = new JButton("ADD VEHICLE"); 699 | btnNewButton_2.setForeground(Color.WHITE); 700 | btnNewButton_2.setBackground(Color.BLUE); 701 | btnNewButton_2.addActionListener(new ActionListener() { 702 | public void actionPerformed(ActionEvent e) { 703 | 704 | panel_2.removeAll(); 705 | panel_2.add(panel_4); 706 | panel_2.repaint(); 707 | panel_2.revalidate(); 708 | } 709 | }); 710 | btnNewButton_2.setBounds(25, 394, 126, 70); 711 | panel.add(btnNewButton_2); 712 | 713 | JButton btnViewOwner = new JButton("VIEW OWNER"); 714 | btnViewOwner.setForeground(Color.WHITE); 715 | btnViewOwner.setBackground(Color.BLUE); 716 | 717 | btnViewOwner.setBounds(25, 306, 126, 70); 718 | panel.add(btnViewOwner); 719 | 720 | JButton btnNewButton_1 = new JButton("VIEW VEHICLE"); 721 | btnNewButton_1.addActionListener(new ActionListener() { 722 | public void actionPerformed(ActionEvent e) { 723 | 724 | panel_2.removeAll(); 725 | panel_2.add(panel_7); 726 | panel_2.repaint(); 727 | panel_2.revalidate(); 728 | 729 | 730 | DefaultTableModel tb2 = new DefaultTableModel (0,0); 731 | 732 | tb2.addColumn("slno"); 733 | tb2.addColumn("ID"); 734 | tb2.addColumn("VEHICLE NUMBER"); 735 | tb2.addColumn("OWNER NAME"); 736 | tb2.addColumn("TYPE OF VEHICLE"); 737 | tb2.addColumn("MODEL"); 738 | tb2.addColumn("COLOR"); 739 | tb2.addColumn("YEAR OF MANUFACTURE"); 740 | tb2.addColumn("DELETE"); 741 | 742 | 743 | 744 | Object rowtb[] = new Object[8]; 745 | 746 | JTable table = new JTable(); 747 | table.setFont(new Font("Times New Roman", Font.BOLD, 17)); 748 | table.setBorder(new LineBorder(Color.LIGHT_GRAY,2)); 749 | table.setAlignmentX(Component.RIGHT_ALIGNMENT); 750 | table.setBackground(Color.PINK); 751 | table.setForeground(Color.WHITE); 752 | table.setRowHeight(50); 753 | 754 | 755 | 756 | scrollPane_2.setColumnHeaderView(table); 757 | 758 | table.setModel(tb2); 759 | 760 | table.getColumn("DELETE").setCellRenderer(new ButtonRendererrej()); 761 | table.getColumn("DELETE").setCellEditor( 762 | new ButtonEditorrej(new JCheckBox())); 763 | scrollPane_2.setViewportView(table); 764 | 765 | 766 | 767 | 768 | tb2.getDataVector().removeAllElements(); 769 | tb2.fireTableDataChanged(); 770 | 771 | 772 | 773 | try 774 | { 775 | Class.forName("com.mysql.jdbc.Driver"); 776 | Connection conn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 777 | 778 | 779 | 780 | PreparedStatement ps = conn1.prepareStatement("select * from vehicle where status='0'"); 781 | 782 | ResultSet rs = (ResultSet) ps.executeQuery(); 783 | int i = 0; 784 | while(rs.next()) { 785 | String sl="1"; 786 | String id= rs.getString("id"); 787 | String vname= rs.getString("v_no"); 788 | String oname= rs.getString("own_name"); 789 | String type= rs.getString("type"); 790 | String mdl= rs.getString("model"); 791 | String clr= rs.getString("color"); 792 | String yr=rs.getString("year"); 793 | 794 | 795 | 796 | /*tb2.addRow(new Object[] {id, vname, oname, type, mdl, clr, yr});*/ 797 | 798 | rowtb[0]=id; 799 | rowtb[1]=id; 800 | rowtb[2]=vname; 801 | rowtb[3]=oname; 802 | rowtb[4]=type; 803 | rowtb[5]=mdl; 804 | rowtb[6]=clr; 805 | rowtb[7]=yr; 806 | 807 | rowtb[7]="Delete"; 808 | 809 | tb2.addRow(rowtb); 810 | scrollPane_2.setViewportView(table); 811 | 812 | i++; 813 | } 814 | } 815 | catch(Exception ex) 816 | { 817 | ex.printStackTrace(); 818 | } 819 | 820 | 821 | 822 | } 823 | }); 824 | btnNewButton_1.setBackground(Color.BLUE); 825 | btnNewButton_1.setForeground(Color.WHITE); 826 | btnNewButton_1.setBounds(25, 482, 126, 70); 827 | panel.add(btnNewButton_1); 828 | 829 | JLabel lblNewLabel_4 = new JLabel("New label"); 830 | lblNewLabel_4.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\Capturead.JPG")); 831 | lblNewLabel_4.setBounds(52, 11, 76, 100); 832 | panel.add(lblNewLabel_4); 833 | 834 | JLabel lblNewLabel_6 = new JLabel("New label"); 835 | lblNewLabel_6.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\2277.jpg")); 836 | lblNewLabel_6.setBounds(10, 0, 164, 675); 837 | panel.add(lblNewLabel_6); 838 | 839 | JButton btnNewButton_4 = new JButton("HOME"); 840 | btnNewButton_4.setBackground(Color.BLACK); 841 | btnNewButton_4.setForeground(Color.WHITE); 842 | btnNewButton_4.addActionListener(new ActionListener() { 843 | public void actionPerformed(ActionEvent e) { 844 | 845 | panel_2.removeAll(); 846 | panel_2.add(panel_5); 847 | panel_2.repaint(); 848 | panel_2.revalidate(); 849 | 850 | } 851 | }); 852 | 853 | 854 | JButton btnLogout = new JButton("LOGOUT"); 855 | btnLogout.addActionListener(new ActionListener() { 856 | public void actionPerformed(ActionEvent arg0) { 857 | 858 | proj2 window = new proj2(); 859 | window.frame.setVisible(true); 860 | admin1.this.frame.setVisible(false); 861 | } 862 | }); 863 | btnLogout.setForeground(Color.WHITE); 864 | btnLogout.setBackground(Color.BLACK); 865 | btnLogout.setBounds(1251, 11, 89, 27); 866 | panel_1.add(btnLogout); 867 | btnNewButton_4.setBounds(1139, 11, 102, 27); 868 | panel_1.add(btnNewButton_4); 869 | 870 | JLabel lblNewLabel_5 = new JLabel("New label"); 871 | lblNewLabel_5.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\119061.jpg")); 872 | lblNewLabel_5.setBounds(0, 0, 1383, 49); 873 | panel_1.add(lblNewLabel_5); 874 | 875 | JLabel lblNewLabel_12 = new JLabel("New label"); 876 | lblNewLabel_12.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\2277.jpg")); 877 | lblNewLabel_12.setBounds(0, 49, 1370, 20); 878 | frame.getContentPane().add(lblNewLabel_12); 879 | 880 | 881 | btnViewOwner.addActionListener(new ActionListener() { 882 | public void actionPerformed(ActionEvent e) { 883 | panel_2.removeAll(); 884 | panel_2.add(panel_6); 885 | panel_2.repaint(); 886 | panel_2.revalidate(); 887 | 888 | 889 | 890 | 891 | DefaultTableModel tb1 = new DefaultTableModel (0,0); 892 | 893 | tb1.addColumn("Sl No"); 894 | tb1.addColumn("ID"); 895 | tb1.addColumn("NAME"); 896 | tb1.addColumn("GENDER"); 897 | tb1.addColumn("DOB"); 898 | tb1.addColumn("ADDRESS"); 899 | tb1.addColumn("PHONE NUMBER"); 900 | tb1.addColumn("LICENSE NUMBER"); 901 | tb1.addColumn("USERNAME"); 902 | tb1.addColumn("PASSWORD"); 903 | tb1.addColumn("DELETE"); 904 | 905 | 906 | 907 | Object rowtb1[] = new Object[11]; 908 | 909 | JTable table_1 = new JTable(); 910 | table_1.setFont(new Font("Times New Roman", Font.BOLD, 17)); 911 | table_1.setBorder(new LineBorder(Color.LIGHT_GRAY,2)); 912 | table_1.setAlignmentX(Component.RIGHT_ALIGNMENT); 913 | table_1.setBackground(Color.PINK); 914 | table_1.setForeground(Color.WHITE); 915 | table_1.setRowHeight(50); 916 | 917 | 918 | 919 | scrollPane_1.setColumnHeaderView(table_1); 920 | 921 | table_1.setModel(tb1); 922 | 923 | table_1.getColumn("DELETE").setCellRenderer(new ButtonRenderer()); 924 | table_1.getColumn("DELETE").setCellEditor( 925 | new ButtonEditor(new JCheckBox())); 926 | scrollPane_1.setViewportView(table_1); 927 | 928 | 929 | 930 | 931 | tb1.getDataVector().removeAllElements(); 932 | tb1.fireTableDataChanged(); 933 | 934 | 935 | try 936 | { 937 | Class.forName("com.mysql.jdbc.Driver"); 938 | Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 939 | 940 | 941 | 942 | PreparedStatement ps = conn.prepareStatement("select * from owner_details where status='0'"); 943 | 944 | ResultSet rs = (ResultSet) ps.executeQuery(); 945 | int i = 0; 946 | 947 | while(rs.next()) { 948 | String slno="1"; 949 | String id= rs.getString("id"); 950 | String name= rs.getString("own_name"); 951 | String gender= rs.getString("own_gend"); 952 | String dob= rs.getString("own_dob"); 953 | String address= rs.getString("own_add"); 954 | String phone= rs.getString("own_phn"); 955 | String license=rs.getString("own_lice"); 956 | String uname=rs.getString("user"); 957 | String pass=rs.getString("passw"); 958 | 959 | 960 | 961 | 962 | 963 | //tb1.addRow(new Object[] {"id",id, name, gender, dob, address, phone, license, uname, pass}); 964 | 965 | rowtb1[0]=slno; 966 | rowtb1[1]=id; 967 | rowtb1[2]=name; 968 | rowtb1[3]=gender; 969 | rowtb1[4]=dob; 970 | rowtb1[5]=address; 971 | rowtb1[6]=phone; 972 | rowtb1[7]=license; 973 | rowtb1[8]=uname; 974 | rowtb1[9]=pass; 975 | rowtb1[10]="Delete"; 976 | 977 | 978 | 979 | 980 | tb1.addRow(rowtb1); 981 | scrollPane_1.setViewportView(table_1); 982 | 983 | i++; 984 | } 985 | } 986 | catch(Exception ex) 987 | { 988 | ex.printStackTrace(); 989 | } 990 | 991 | 992 | 993 | 994 | } 995 | }); 996 | 997 | 998 | 999 | btnSubmit.addActionListener(new ActionListener() { 1000 | public void actionPerformed(ActionEvent arg0) { 1001 | 1002 | String oname=textField.getText(); 1003 | String dob=textField_2.getText(); 1004 | String Addr=textArea.getText(); 1005 | String Phn=textField_1.getText(); 1006 | String Lice=textField_3.getText(); 1007 | String Usname=textField_9.getText(); 1008 | String Passwd=textField_10.getText(); 1009 | 1010 | String qual = " "; 1011 | 1012 | // If condition to check if jRadioButton2 is selected. 1013 | if (rdbtnMale.isSelected()) { 1014 | 1015 | qual = "Male"; 1016 | } 1017 | 1018 | else if (rdbtnFemale.isSelected()) { 1019 | 1020 | qual = "Female"; 1021 | } 1022 | else { 1023 | 1024 | qual = "NO Button selected"; 1025 | } 1026 | if(textField.getText().isEmpty()||textField_2.getText().isEmpty()||textArea.getText().isEmpty()||textField_1.getText().isEmpty()||textField_3.getText().isEmpty()||textField_9.getText().isEmpty()||textField_10.getText().isEmpty()) 1027 | 1028 | { 1029 | if(textField.getText().isEmpty()) { 1030 | errorname.setText("*enter valid name"); 1031 | } 1032 | if(textField.getText().isEmpty()) { 1033 | errordob.setText("*fill the field "); 1034 | 1035 | } 1036 | if(textArea.getText().isEmpty()) { 1037 | errorad.setText("*enter the address"); 1038 | } 1039 | if(textField_1.getText().isEmpty()) { 1040 | errorph.setText("*enter the phone no:"); 1041 | } 1042 | if(textField_3.getText().isEmpty()) { 1043 | errorli.setText("*enter the license no:"); 1044 | } 1045 | } 1046 | else 1047 | { 1048 | try 1049 | { 1050 | Class.forName("com.mysql.jdbc.Driver"); 1051 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 1052 | Statement st=con.createStatement(); 1053 | int j=st.executeUpdate("insert into owner_details(own_name,own_gend,own_dob,own_add,own_phn,own_lice,user,passw) values('"+oname+"','"+qual+"','"+dob+"','"+Addr+"','"+Phn+"','"+Lice+"','"+Usname+"','"+Passwd+"')"); 1054 | 1055 | 1056 | JOptionPane.showMessageDialog(null,"REGISTRATION SUCCESSFUL"); 1057 | } 1058 | 1059 | catch(Exception e) 1060 | { 1061 | System.out.println(e); 1062 | e.printStackTrace(); 1063 | } 1064 | } 1065 | textField.setText(""); 1066 | textField_2.setText(""); 1067 | textArea.setText(""); 1068 | textField_1.setText(""); 1069 | textField_3.setText(""); 1070 | textField_9.setText(""); 1071 | textField_10.setText(""); 1072 | G1.clearSelection(); 1073 | 1074 | Refresh(); 1075 | 1076 | } 1077 | 1078 | private void Refresh() { 1079 | // TODO Auto-generated method stub 1080 | 1081 | } 1082 | }); 1083 | 1084 | 1085 | } 1086 | } 1087 | 1088 | 1089 | 1090 | 1091 | -------------------------------------------------------------------------------- /admin.java: -------------------------------------------------------------------------------- 1 | package proj1; 2 | 3 | import java.awt.EventQueue; 4 | 5 | import javax.swing.JFrame; 6 | import javax.swing.JPanel; 7 | import javax.swing.JButton; 8 | import javax.swing.JCheckBox; 9 | 10 | import java.awt.CardLayout; 11 | import javax.swing.JLabel; 12 | import javax.swing.JOptionPane; 13 | import javax.swing.JTextField; 14 | import javax.swing.UIManager; 15 | import javax.swing.border.LineBorder; 16 | import javax.swing.table.DefaultTableModel; 17 | import javax.swing.table.TableCellRenderer; 18 | 19 | import com.mysql.jdbc.ResultSet; 20 | 21 | import javax.swing.JRadioButton; 22 | import javax.swing.JScrollPane; 23 | import javax.swing.JTable; 24 | import javax.swing.JTextArea; 25 | import java.awt.Color; 26 | import java.awt.Component; 27 | import java.awt.Font; 28 | import java.awt.Frame; 29 | 30 | import javax.swing.ButtonGroup; 31 | import javax.swing.DefaultCellEditor; 32 | import javax.swing.ImageIcon; 33 | import java.awt.event.ActionListener; 34 | import java.sql.Connection; 35 | import java.sql.DriverManager; 36 | import java.sql.PreparedStatement; 37 | import java.sql.Statement; 38 | import java.awt.event.ActionEvent; 39 | import java.awt.event.KeyAdapter; 40 | import java.awt.event.KeyEvent; 41 | 42 | 43 | public class admin { 44 | 45 | JFrame frame; 46 | private JTextField textField; 47 | private JTextField textField_2; 48 | private JTextField textField_1; 49 | private JTextField textField_3; 50 | private JTextField textField_4; 51 | private JTextField textField_5; 52 | private JTextField textField_6; 53 | private JTextField textField_7; 54 | private JTextField textField_8; 55 | private JTextField textField_9; 56 | /*private JPasswordField passwordField;*/ 57 | private JTextField textField_10; 58 | private JTable table; 59 | 60 | /** 61 | * Launch the application. 62 | */ 63 | public static void main(String[] args) { 64 | EventQueue.invokeLater(new Runnable() { 65 | public void run() { 66 | try { 67 | admin window = new admin(); 68 | window.frame.setVisible(true); 69 | } catch (Exception e) { 70 | e.printStackTrace(); 71 | } 72 | } 73 | }); 74 | } 75 | 76 | /** 77 | * Create the application. 78 | */ 79 | public admin() { 80 | initialize(); 81 | } 82 | 83 | /** 84 | * Initialize the contents of the frame. 85 | */ 86 | private void initialize() { 87 | 88 | ButtonGroup G1; 89 | G1 = new ButtonGroup(); 90 | 91 | frame = new JFrame(); 92 | frame.setBounds(100, 100, 1413, 788); 93 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 94 | frame.getContentPane().setLayout(null); 95 | 96 | JPanel panel = new JPanel(); 97 | panel.setBounds(-11, 69, 174, 675); 98 | frame.getContentPane().add(panel); 99 | panel.setLayout(null); 100 | 101 | 102 | 103 | JPanel panel_1 = new JPanel(); 104 | panel_1.setBounds(0, 0, 1370, 49); 105 | frame.getContentPane().add(panel_1); 106 | panel_1.setLayout(null); 107 | 108 | 109 | 110 | 111 | JPanel panel_2 = new JPanel(); 112 | panel_2.setBounds(161, 68, 1209, 681); 113 | frame.getContentPane().add(panel_2); 114 | panel_2.setLayout(new CardLayout(0, 0)); 115 | 116 | JPanel panel_5 = new JPanel(); 117 | panel_2.add(panel_5, "name_612598371549080"); 118 | panel_5.setLayout(null); 119 | 120 | JLabel label_16 = new JLabel("to change the world for good"); 121 | label_16.setForeground(Color.WHITE); 122 | label_16.setFont(new Font("Bookman Old Style", Font.PLAIN, 25)); 123 | label_16.setBounds(333, 497, 406, 39); 124 | panel_5.add(label_16); 125 | 126 | JLabel label_15 = new JLabel("Driving innovation"); 127 | label_15.setForeground(Color.WHITE); 128 | label_15.setFont(new Font("Bookman Old Style", Font.BOLD, 35)); 129 | label_15.setBounds(333, 430, 359, 56); 130 | panel_5.add(label_15); 131 | 132 | JLabel label_14 = new JLabel("WELCOME"); 133 | label_14.setForeground(Color.WHITE); 134 | label_14.setFont(new Font("Bookman Old Style", Font.BOLD, 70)); 135 | label_14.setBounds(244, 213, 415, 85); 136 | panel_5.add(label_14); 137 | 138 | JLabel lblNewLabel_11 = new JLabel(""); 139 | lblNewLabel_11.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\2017-12_CarHop_Website_1600x850_88944735-1600x850.jpg")); 140 | lblNewLabel_11.setBounds(0, 0, 1219, 696); 141 | panel_5.add(lblNewLabel_11); 142 | 143 | JPanel panel_3 = new JPanel(); 144 | panel_2.add(panel_3, "name_577813858504149"); 145 | panel_3.setLayout(null); 146 | 147 | 148 | 149 | JButton btnSubmit = new JButton("SUBMIT"); 150 | 151 | btnSubmit.setForeground(Color.WHITE); 152 | btnSubmit.setBackground(Color.GRAY); 153 | btnSubmit.setBounds(675, 549, 119, 47); 154 | panel_3.add(btnSubmit); 155 | 156 | 157 | 158 | JLabel errorad = new JLabel(""); 159 | errorad.setForeground(Color.RED); 160 | errorad.setBounds(674, 316, 120, 14); 161 | panel_3.add(errorad); 162 | 163 | 164 | 165 | JLabel errorname = new JLabel(""); 166 | errorname.setForeground(Color.RED); 167 | errorname.setBounds(674, 164, 190, 14); 168 | panel_3.add(errorname); 169 | 170 | JLabel errordob = new JLabel(""); 171 | errordob.setForeground(Color.RED); 172 | errordob.setBounds(674, 262, 158, 14); 173 | panel_3.add(errordob); 174 | 175 | JLabel errorph = new JLabel(""); 176 | errorph.setForeground(Color.RED); 177 | errorph.setBounds(674, 370, 135, 14); 178 | panel_3.add(errorph); 179 | 180 | JLabel errorli = new JLabel(""); 181 | errorli.setForeground(Color.RED); 182 | errorli.setBounds(672, 427, 137, 14); 183 | panel_3.add(errorli); 184 | 185 | 186 | 187 | textField_10 = new JTextField(); 188 | textField_10.setBounds(674, 500, 171, 25); 189 | panel_3.add(textField_10); 190 | textField_10.setColumns(10); 191 | 192 | JLabel lblOwnerRegistration = new JLabel("OWNER REGISTRATION"); 193 | lblOwnerRegistration.setFont(new Font("Verdana", Font.BOLD | Font.ITALIC, 20)); 194 | lblOwnerRegistration.setForeground(Color.CYAN); 195 | lblOwnerRegistration.setBounds(466, 67, 289, 33); 196 | panel_3.add(lblOwnerRegistration); 197 | 198 | JLabel lblName = new JLabel("NAME"); 199 | lblName.setFont(new Font("Verdana", Font.BOLD, 12)); 200 | lblName.setBounds(373, 133, 79, 21); 201 | panel_3.add(lblName); 202 | 203 | textField = new JTextField(); 204 | textField.setBounds(675, 128, 170, 25); 205 | panel_3.add(textField); 206 | textField.setColumns(10); 207 | 208 | JLabel lblNewLabel = new JLabel("GENDER"); 209 | lblNewLabel.setFont(new Font("Verdana", Font.BOLD, 12)); 210 | lblNewLabel.setBounds(373, 188, 79, 14); 211 | panel_3.add(lblNewLabel); 212 | 213 | JLabel lblDob = new JLabel("DOB"); 214 | lblDob.setFont(new Font("Verdana", Font.BOLD, 12)); 215 | lblDob.setBounds(373, 238, 46, 14); 216 | panel_3.add(lblDob); 217 | 218 | textField_2 = new JTextField(); 219 | textField_2.setBounds(674, 230, 171, 25); 220 | panel_3.add(textField_2); 221 | textField_2.setColumns(10); 222 | 223 | JRadioButton rdbtnMale = new JRadioButton("MALE"); 224 | rdbtnMale.setBounds(675, 185, 79, 23); 225 | panel_3.add(rdbtnMale); 226 | 227 | JRadioButton rdbtnFemale = new JRadioButton("FEMALE"); 228 | rdbtnFemale.setBounds(756, 185, 89, 23); 229 | panel_3.add(rdbtnFemale); 230 | 231 | 232 | G1.add(rdbtnMale); 233 | G1.add(rdbtnFemale); 234 | 235 | 236 | JLabel lblAddress = new JLabel("ADDRESS"); 237 | lblAddress.setFont(new Font("Verdana", Font.BOLD, 12)); 238 | lblAddress.setBounds(373, 287, 79, 14); 239 | panel_3.add(lblAddress); 240 | 241 | JLabel lblPhoneNumber = new JLabel("PHONE NUMBER"); 242 | lblPhoneNumber.setFont(new Font("Verdana", Font.BOLD, 12)); 243 | lblPhoneNumber.setBounds(373, 344, 109, 14); 244 | panel_3.add(lblPhoneNumber); 245 | 246 | JTextArea textArea = new JTextArea(); 247 | textArea.setBounds(675, 272, 170, 41); 248 | panel_3.add(textArea); 249 | 250 | textField_1 = new JTextField(); 251 | textField_1.addKeyListener(new KeyAdapter() { 252 | @Override 253 | public void keyPressed(java.awt.event.KeyEvent evt) { 254 | String Phn=textField_1.getText(); 255 | int length=Phn.length(); 256 | char c=evt.getKeyChar(); 257 | if(evt.getKeyChar()>='0' && evt.getKeyChar()<='9') 258 | { 259 | 260 | if(length<10) 261 | { 262 | textField_1.setEditable(true); 263 | errorph.setText("*enter 10 digits:"); 264 | } 265 | 266 | 267 | else 268 | { 269 | textField_1.setEditable(false); 270 | errorph.setText(""); 271 | } 272 | } 273 | else 274 | { 275 | if(evt.getExtendedKeyCode()==KeyEvent.VK_BACK_SPACE||evt.getExtendedKeyCode()==KeyEvent.VK_DELETE) 276 | { 277 | textField_1.setEditable(true); 278 | } 279 | 280 | else { 281 | textField_1.setEditable(false); 282 | } 283 | } 284 | } 285 | 286 | }); 287 | textField_1.setBounds(675, 336, 170, 23); 288 | panel_3.add(textField_1); 289 | textField_1.setColumns(10); 290 | 291 | JLabel lblLicenseNumber = new JLabel("LICENSE NUMBER"); 292 | lblLicenseNumber.setFont(new Font("Verdana", Font.BOLD, 12)); 293 | lblLicenseNumber.setBounds(373, 403, 129, 14); 294 | panel_3.add(lblLicenseNumber); 295 | 296 | textField_3 = new JTextField(); 297 | textField_3.setBounds(674, 395, 171, 22); 298 | panel_3.add(textField_3); 299 | textField_3.setColumns(10); 300 | 301 | 302 | 303 | JLabel label = new JLabel(":"); 304 | label.setFont(new Font("Tahoma", Font.BOLD, 12)); 305 | label.setBounds(545, 136, 46, 14); 306 | panel_3.add(label); 307 | 308 | JLabel label_1 = new JLabel(":"); 309 | label_1.setFont(new Font("Tahoma", Font.BOLD, 12)); 310 | label_1.setBounds(545, 188, 46, 14); 311 | panel_3.add(label_1); 312 | 313 | JLabel label_2 = new JLabel(":"); 314 | label_2.setFont(new Font("Tahoma", Font.BOLD, 12)); 315 | label_2.setBounds(545, 238, 46, 14); 316 | panel_3.add(label_2); 317 | 318 | JLabel label_3 = new JLabel(":"); 319 | label_3.setFont(new Font("Tahoma", Font.BOLD, 12)); 320 | label_3.setBounds(545, 287, 46, 14); 321 | panel_3.add(label_3); 322 | 323 | JLabel label_4 = new JLabel(":"); 324 | label_4.setFont(new Font("Tahoma", Font.BOLD, 12)); 325 | label_4.setBounds(545, 344, 46, 14); 326 | panel_3.add(label_4); 327 | 328 | JLabel label_5 = new JLabel(":"); 329 | label_5.setFont(new Font("Tahoma", Font.BOLD, 12)); 330 | label_5.setBounds(545, 403, 46, 14); 331 | panel_3.add(label_5); 332 | 333 | JLabel lblNewLabel_9 = new JLabel("New label"); 334 | lblNewLabel_9.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\1920x1080-white-solid-color-background.jpg")); 335 | lblNewLabel_9.setBounds(292, 58, 620, 59); 336 | panel_3.add(lblNewLabel_9); 337 | 338 | JLabel lblUsername = new JLabel("USERNAME"); 339 | lblUsername.setFont(new Font("Verdana", Font.BOLD, 12)); 340 | lblUsername.setBounds(373, 456, 109, 14); 341 | panel_3.add(lblUsername); 342 | 343 | JLabel lblNewLabel_13 = new JLabel(":"); 344 | lblNewLabel_13.setFont(new Font("Tahoma", Font.BOLD, 12)); 345 | lblNewLabel_13.setBounds(545, 456, 46, 14); 346 | panel_3.add(lblNewLabel_13); 347 | 348 | textField_9 = new JTextField(); 349 | textField_9.setBounds(674, 448, 171, 22); 350 | panel_3.add(textField_9); 351 | textField_9.setColumns(10); 352 | 353 | JLabel lblPassword = new JLabel("PASSWORD"); 354 | lblPassword.setFont(new Font("Verdana", Font.BOLD, 12)); 355 | lblPassword.setBounds(373, 508, 109, 14); 356 | panel_3.add(lblPassword); 357 | 358 | JLabel label_13 = new JLabel(":"); 359 | label_13.setFont(new Font("Tahoma", Font.BOLD, 12)); 360 | label_13.setBounds(545, 508, 46, 14); 361 | panel_3.add(label_13); 362 | 363 | JLabel lblNewLabel_1 = new JLabel("New label"); 364 | lblNewLabel_1.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\wallpapers-plain-colors-26.jpg")); 365 | lblNewLabel_1.setBounds(292, 114, 620, 527); 366 | panel_3.add(lblNewLabel_1); 367 | 368 | JLabel lblNewLabel_10 = new JLabel("New label"); 369 | lblNewLabel_10.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\bg7.jpg")); 370 | lblNewLabel_10.setBounds(0, 0, 1178, 701); 371 | panel_3.add(lblNewLabel_10); 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | JPanel panel_4 = new JPanel(); 380 | panel_2.add(panel_4, "name_579286929612941"); 381 | panel_4.setLayout(null); 382 | 383 | JLabel errornumb = new JLabel(""); 384 | errornumb.setForeground(Color.RED); 385 | errornumb.setBounds(637, 180, 151, 14); 386 | panel_4.add(errornumb); 387 | 388 | JLabel erroroname = new JLabel(""); 389 | erroroname.setForeground(Color.RED); 390 | erroroname.setBounds(637, 246, 169, 14); 391 | panel_4.add(erroroname); 392 | 393 | JLabel errormod = new JLabel(""); 394 | errormod.setForeground(Color.RED); 395 | errormod.setBounds(637, 348, 151, 14); 396 | panel_4.add(errormod); 397 | 398 | 399 | JLabel lblVehicleRegistration = new JLabel("VEHICLE REGISTRATION"); 400 | lblVehicleRegistration.setForeground(Color.CYAN); 401 | lblVehicleRegistration.setFont(new Font("Verdana", Font.BOLD | Font.ITALIC, 20)); 402 | lblVehicleRegistration.setBounds(455, 90, 288, 24); 403 | panel_4.add(lblVehicleRegistration); 404 | 405 | JLabel label_6 = new JLabel("VEHICLE NUMBER"); 406 | label_6.setForeground(Color.BLACK); 407 | label_6.setFont(new Font("Verdana", Font.BOLD, 12)); 408 | label_6.setBounds(315, 155, 151, 20); 409 | panel_4.add(label_6); 410 | 411 | textField_4 = new JTextField(); 412 | textField_4.setColumns(10); 413 | textField_4.setBounds(637, 151, 175, 24); 414 | panel_4.add(textField_4); 415 | 416 | JLabel lblOwnerName = new JLabel("OWNER NAME"); 417 | lblOwnerName.setForeground(Color.BLACK); 418 | lblOwnerName.setFont(new Font("Verdana", Font.BOLD, 12)); 419 | lblOwnerName.setBounds(315, 207, 110, 24); 420 | panel_4.add(lblOwnerName); 421 | 422 | textField_5 = new JTextField(); 423 | textField_5.setBounds(637, 205, 175, 24); 424 | panel_4.add(textField_5); 425 | textField_5.setColumns(10); 426 | 427 | JLabel lblNewLabel_2 = new JLabel("TYPE OF VEHICLE"); 428 | lblNewLabel_2.setForeground(Color.BLACK); 429 | lblNewLabel_2.setFont(new Font("Verdana", Font.BOLD, 12)); 430 | lblNewLabel_2.setBounds(316, 268, 130, 19); 431 | panel_4.add(lblNewLabel_2); 432 | 433 | JRadioButton radioButton = new JRadioButton("Car"); 434 | radioButton.setFont(new Font("Verdana", Font.PLAIN, 12)); 435 | radioButton.setBounds(637, 265, 61, 24); 436 | panel_4.add(radioButton); 437 | 438 | JRadioButton radioButton_1 = new JRadioButton("Van"); 439 | radioButton_1.setFont(new Font("Verdana", Font.PLAIN, 12)); 440 | radioButton_1.setBounds(710, 265, 55, 24); 441 | panel_4.add(radioButton_1); 442 | 443 | JRadioButton radioButton_2 = new JRadioButton("Bus"); 444 | radioButton_2.setFont(new Font("Verdana", Font.PLAIN, 12)); 445 | radioButton_2.setBounds(778, 266, 61, 23); 446 | panel_4.add(radioButton_2); 447 | 448 | JRadioButton rdbtnOther = new JRadioButton("Other"); 449 | rdbtnOther.setFont(new Font("Verdana", Font.PLAIN, 12)); 450 | rdbtnOther.setBounds(852, 265, 73, 24); 451 | panel_4.add(rdbtnOther); 452 | 453 | G1.add(radioButton); 454 | G1.add(radioButton_1); 455 | G1.add(radioButton_2); 456 | G1.add(rdbtnOther); 457 | 458 | 459 | 460 | JLabel lblModel = new JLabel("MODEL"); 461 | lblModel.setForeground(Color.BLACK); 462 | lblModel.setFont(new Font("Verdana", Font.BOLD, 12)); 463 | lblModel.setBounds(316, 324, 73, 14); 464 | panel_4.add(lblModel); 465 | 466 | textField_6 = new JTextField(); 467 | textField_6.setBounds(637, 317, 175, 24); 468 | panel_4.add(textField_6); 469 | textField_6.setColumns(10); 470 | 471 | JLabel lblColor = new JLabel("COLOR"); 472 | lblColor.setForeground(Color.BLACK); 473 | lblColor.setFont(new Font("Verdana", Font.BOLD, 12)); 474 | lblColor.setBounds(315, 380, 74, 14); 475 | panel_4.add(lblColor); 476 | 477 | textField_7 = new JTextField(); 478 | textField_7.setBounds(637, 373, 175, 24); 479 | panel_4.add(textField_7); 480 | textField_7.setColumns(10); 481 | 482 | JLabel lblYearOfManufacture = new JLabel("YEAR OF MANUFACTURE"); 483 | lblYearOfManufacture.setForeground(Color.BLACK); 484 | lblYearOfManufacture.setFont(new Font("Verdana", Font.BOLD, 12)); 485 | lblYearOfManufacture.setBounds(315, 432, 169, 24); 486 | panel_4.add(lblYearOfManufacture); 487 | 488 | textField_8 = new JTextField(); 489 | textField_8.setBounds(637, 430, 175, 24); 490 | panel_4.add(textField_8); 491 | textField_8.setColumns(10); 492 | 493 | JButton btnSubmit_1 = new JButton("SUBMIT"); 494 | btnSubmit_1.addActionListener(new ActionListener() { 495 | public void actionPerformed(ActionEvent arg0) { 496 | 497 | String vnum=textField_4.getText(); 498 | String oname=textField_5.getText(); 499 | String mod=textField_6.getText(); 500 | String clr=textField_7.getText(); 501 | String yr=textField_8.getText(); 502 | String typ = " "; 503 | 504 | // If condition to check if jRadioButton2 is selected. 505 | if (radioButton.isSelected()) { 506 | 507 | typ= "Car"; 508 | } 509 | 510 | else if (radioButton_1.isSelected()) { 511 | 512 | typ = "Van"; 513 | } 514 | else if (radioButton_2.isSelected()) { 515 | 516 | typ= "Bus"; 517 | } 518 | 519 | else if (rdbtnOther.isSelected()) { 520 | 521 | typ= "Other"; 522 | } 523 | else { 524 | typ="no selected"; 525 | } 526 | if(textField_4.getText().isEmpty()||textField_5.getText().isEmpty()||textField_6.getText().isEmpty()||textField_7.getText().isEmpty()||textField_8.getText().isEmpty()) 527 | { 528 | if(textField_4.getText().isEmpty()) { 529 | errornumb.setText("*enter valid number"); 530 | } 531 | if(textField_5.getText().isEmpty()) { 532 | erroroname.setText("*enter valid name"); 533 | } 534 | if(textField_6.getText().isEmpty()) { 535 | errormod.setText("*enter model name"); 536 | } 537 | 538 | } 539 | else 540 | { 541 | 542 | 543 | try 544 | { 545 | Class.forName("com.mysql.jdbc.Driver"); 546 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 547 | Statement st=con.createStatement(); 548 | int k=st.executeUpdate("insert into vehicle(v_no,own_name,type,model,color,year) values('"+vnum+"','"+oname+"','"+typ+"','"+mod+"','"+clr+"','"+yr+"')"); 549 | 550 | 551 | JOptionPane.showMessageDialog(null,"REGISTRATION SUCCESSFUL"); 552 | } 553 | catch(Exception e) 554 | { 555 | System.out.println(e); 556 | e.printStackTrace(); 557 | } 558 | } 559 | textField_4.setText(""); 560 | textField_5.setText(""); 561 | textField_6.setText(""); 562 | textField_7.setText(""); 563 | textField_8.setText(""); 564 | 565 | G1.clearSelection(); 566 | 567 | Refresh(); 568 | 569 | } 570 | 571 | private void Refresh() { 572 | // TODO Auto-generated method stub 573 | 574 | } 575 | }); 576 | btnSubmit_1.setForeground(Color.WHITE); 577 | btnSubmit_1.setBackground(Color.GRAY); 578 | btnSubmit_1.setBounds(637, 491, 122, 51); 579 | panel_4.add(btnSubmit_1); 580 | 581 | JLabel label_7 = new JLabel(":"); 582 | label_7.setForeground(Color.WHITE); 583 | label_7.setFont(new Font("Tahoma", Font.BOLD, 12)); 584 | label_7.setBounds(545, 158, 46, 14); 585 | panel_4.add(label_7); 586 | 587 | JLabel label_8 = new JLabel(":"); 588 | label_8.setForeground(Color.WHITE); 589 | label_8.setFont(new Font("Tahoma", Font.BOLD, 12)); 590 | label_8.setBounds(545, 212, 46, 14); 591 | panel_4.add(label_8); 592 | 593 | JLabel label_9 = new JLabel(":"); 594 | label_9.setForeground(Color.WHITE); 595 | label_9.setFont(new Font("Tahoma", Font.BOLD, 12)); 596 | label_9.setBounds(545, 270, 46, 14); 597 | panel_4.add(label_9); 598 | 599 | JLabel label_10 = new JLabel(":"); 600 | label_10.setForeground(Color.WHITE); 601 | label_10.setFont(new Font("Tahoma", Font.BOLD, 12)); 602 | label_10.setBounds(545, 324, 46, 14); 603 | panel_4.add(label_10); 604 | 605 | JLabel label_11 = new JLabel(":"); 606 | label_11.setForeground(Color.WHITE); 607 | label_11.setFont(new Font("Tahoma", Font.BOLD, 12)); 608 | label_11.setBounds(545, 389, 46, 14); 609 | panel_4.add(label_11); 610 | 611 | JLabel label_12 = new JLabel(":"); 612 | label_12.setForeground(Color.WHITE); 613 | label_12.setFont(new Font("Tahoma", Font.BOLD, 12)); 614 | label_12.setBounds(545, 437, 46, 14); 615 | panel_4.add(label_12); 616 | 617 | JLabel lblNewLabel_3 = new JLabel("New label"); 618 | lblNewLabel_3.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\wallpapers-plain-colors-26.jpg")); 619 | lblNewLabel_3.setBounds(254, 125, 689, 447); 620 | panel_4.add(lblNewLabel_3); 621 | 622 | JLabel lblNewLabel_7 = new JLabel("New label"); 623 | lblNewLabel_7.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\1920x1080-white-solid-color-background.jpg")); 624 | lblNewLabel_7.setBackground(Color.GREEN); 625 | lblNewLabel_7.setBounds(254, 72, 689, 56); 626 | panel_4.add(lblNewLabel_7); 627 | 628 | JLabel lblNewLabel_8 = new JLabel("New label"); 629 | lblNewLabel_8.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\o-TYPING-facebook.jpg")); 630 | lblNewLabel_8.setBounds(0, 0, 1209, 696); 631 | panel_4.add(lblNewLabel_8); 632 | 633 | 634 | 635 | 636 | JPanel panel_6 = new JPanel(); 637 | panel_2.add(panel_6, "name_585182201879387"); 638 | panel_6.setLayout(null); 639 | 640 | JScrollPane scrollPane_1 = new JScrollPane(); 641 | scrollPane_1.setBounds(0, 0, 1209, 681); 642 | scrollPane_1.setFont(new Font("Times New Roman", Font.BOLD, 17)); 643 | scrollPane_1.setForeground(Color.WHITE); 644 | scrollPane_1.setBackground(Color.DARK_GRAY); 645 | 646 | panel_6.add(scrollPane_1); 647 | 648 | 649 | 650 | 651 | 652 | 653 | JPanel panel_7 = new JPanel(); 654 | panel_2.add(panel_7, "name_616164740729907"); 655 | panel_7.setLayout(null); 656 | 657 | 658 | 659 | JScrollPane scrollPane_2 = new JScrollPane(); 660 | scrollPane_2.setFont(new Font("Times New Roman", Font.BOLD, 17)); 661 | scrollPane_2.setForeground(Color.WHITE); 662 | scrollPane_2.setBackground(Color.DARK_GRAY); 663 | scrollPane_2.setBounds(0,0,1209,780); 664 | 665 | panel_7.add(scrollPane_2); 666 | 667 | table = new JTable(); 668 | table.setBounds(0, 0, 1, 1); 669 | panel_7.add(table); 670 | 671 | 672 | 673 | 674 | 675 | 676 | JButton btnNewButton = new JButton("ADD OWNER"); 677 | btnNewButton.setForeground(Color.WHITE); 678 | btnNewButton.setBackground(Color.BLUE); 679 | btnNewButton.addActionListener(new ActionListener() { 680 | public void actionPerformed(ActionEvent arg0) { 681 | 682 | panel_2.removeAll(); 683 | panel_2.add(panel_3); 684 | panel_2.repaint(); 685 | panel_2.revalidate(); 686 | 687 | } 688 | }); 689 | 690 | JLabel lblNewLabel_14 = new JLabel("Dashboard"); 691 | lblNewLabel_14.setFont(new Font("Bookman Old Style", Font.BOLD, 21)); 692 | lblNewLabel_14.setForeground(Color.BLUE); 693 | lblNewLabel_14.setBounds(30, 139, 121, 38); 694 | panel.add(lblNewLabel_14); 695 | btnNewButton.setBounds(25, 211, 126, 70); 696 | panel.add(btnNewButton); 697 | 698 | JButton btnNewButton_2 = new JButton("ADD VEHICLE"); 699 | btnNewButton_2.setForeground(Color.WHITE); 700 | btnNewButton_2.setBackground(Color.BLUE); 701 | btnNewButton_2.addActionListener(new ActionListener() { 702 | public void actionPerformed(ActionEvent e) { 703 | 704 | panel_2.removeAll(); 705 | panel_2.add(panel_4); 706 | panel_2.repaint(); 707 | panel_2.revalidate(); 708 | } 709 | }); 710 | btnNewButton_2.setBounds(25, 394, 126, 70); 711 | panel.add(btnNewButton_2); 712 | 713 | JButton btnViewOwner = new JButton("VIEW OWNER"); 714 | btnViewOwner.setForeground(Color.WHITE); 715 | btnViewOwner.setBackground(Color.BLUE); 716 | 717 | btnViewOwner.setBounds(25, 306, 126, 70); 718 | panel.add(btnViewOwner); 719 | 720 | JButton btnNewButton_1 = new JButton("VIEW VEHICLE"); 721 | btnNewButton_1.addActionListener(new ActionListener() { 722 | public void actionPerformed(ActionEvent e) { 723 | 724 | panel_2.removeAll(); 725 | panel_2.add(panel_7); 726 | panel_2.repaint(); 727 | panel_2.revalidate(); 728 | 729 | 730 | DefaultTableModel tb2 = new DefaultTableModel (0,0); 731 | 732 | tb2.addColumn("slno"); 733 | tb2.addColumn("ID"); 734 | tb2.addColumn("VEHICLE NUMBER"); 735 | tb2.addColumn("OWNER NAME"); 736 | tb2.addColumn("TYPE OF VEHICLE"); 737 | tb2.addColumn("MODEL"); 738 | tb2.addColumn("COLOR"); 739 | tb2.addColumn("YEAR OF MANUFACTURE"); 740 | tb2.addColumn("DELETE"); 741 | 742 | 743 | 744 | Object rowtb[] = new Object[8]; 745 | 746 | JTable table = new JTable(); 747 | table.setFont(new Font("Times New Roman", Font.BOLD, 17)); 748 | table.setBorder(new LineBorder(Color.LIGHT_GRAY,2)); 749 | table.setAlignmentX(Component.RIGHT_ALIGNMENT); 750 | table.setBackground(Color.PINK); 751 | table.setForeground(Color.WHITE); 752 | table.setRowHeight(50); 753 | 754 | 755 | 756 | scrollPane_2.setColumnHeaderView(table); 757 | 758 | table.setModel(tb2); 759 | 760 | table.getColumn("DELETE").setCellRenderer(new ButtonRendererrej()); 761 | table.getColumn("DELETE").setCellEditor( 762 | new ButtonEditorrej(new JCheckBox())); 763 | scrollPane_2.setViewportView(table); 764 | 765 | 766 | 767 | 768 | tb2.getDataVector().removeAllElements(); 769 | tb2.fireTableDataChanged(); 770 | 771 | 772 | 773 | try 774 | { 775 | Class.forName("com.mysql.jdbc.Driver"); 776 | Connection conn1=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 777 | 778 | 779 | 780 | PreparedStatement ps = conn1.prepareStatement("select * from vehicle where status='0'"); 781 | 782 | ResultSet rs = (ResultSet) ps.executeQuery(); 783 | int i = 0; 784 | while(rs.next()) { 785 | String sl="1"; 786 | String id= rs.getString("id"); 787 | String vname= rs.getString("v_no"); 788 | String oname= rs.getString("own_name"); 789 | String type= rs.getString("type"); 790 | String mdl= rs.getString("model"); 791 | String clr= rs.getString("color"); 792 | String yr=rs.getString("year"); 793 | 794 | 795 | 796 | /*tb2.addRow(new Object[] {id, vname, oname, type, mdl, clr, yr});*/ 797 | 798 | rowtb[0]=id; 799 | rowtb[1]=id; 800 | rowtb[2]=vname; 801 | rowtb[3]=oname; 802 | rowtb[4]=type; 803 | rowtb[5]=mdl; 804 | rowtb[6]=clr; 805 | rowtb[7]=yr; 806 | 807 | rowtb[7]="Delete"; 808 | 809 | tb2.addRow(rowtb); 810 | scrollPane_2.setViewportView(table); 811 | 812 | i++; 813 | } 814 | } 815 | catch(Exception ex) 816 | { 817 | ex.printStackTrace(); 818 | } 819 | 820 | 821 | 822 | } 823 | }); 824 | btnNewButton_1.setBackground(Color.BLUE); 825 | btnNewButton_1.setForeground(Color.WHITE); 826 | btnNewButton_1.setBounds(25, 482, 126, 70); 827 | panel.add(btnNewButton_1); 828 | 829 | JLabel lblNewLabel_4 = new JLabel("New label"); 830 | lblNewLabel_4.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\Capturead.JPG")); 831 | lblNewLabel_4.setBounds(52, 11, 76, 100); 832 | panel.add(lblNewLabel_4); 833 | 834 | JLabel lblNewLabel_6 = new JLabel("New label"); 835 | lblNewLabel_6.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\2277.jpg")); 836 | lblNewLabel_6.setBounds(10, 0, 164, 675); 837 | panel.add(lblNewLabel_6); 838 | 839 | JButton btnNewButton_4 = new JButton("HOME"); 840 | btnNewButton_4.setBackground(Color.BLACK); 841 | btnNewButton_4.setForeground(Color.WHITE); 842 | btnNewButton_4.addActionListener(new ActionListener() { 843 | public void actionPerformed(ActionEvent e) { 844 | 845 | panel_2.removeAll(); 846 | panel_2.add(panel_5); 847 | panel_2.repaint(); 848 | panel_2.revalidate(); 849 | 850 | } 851 | }); 852 | 853 | 854 | JButton btnLogout = new JButton("LOGOUT"); 855 | btnLogout.addActionListener(new ActionListener() { 856 | public void actionPerformed(ActionEvent arg0) { 857 | 858 | proj2 window = new proj2(); 859 | window.frame.setVisible(true); 860 | admin.this.frame.setVisible(false); 861 | } 862 | }); 863 | btnLogout.setForeground(Color.WHITE); 864 | btnLogout.setBackground(Color.BLACK); 865 | btnLogout.setBounds(1251, 11, 89, 27); 866 | panel_1.add(btnLogout); 867 | btnNewButton_4.setBounds(1139, 11, 102, 27); 868 | panel_1.add(btnNewButton_4); 869 | 870 | JLabel lblNewLabel_5 = new JLabel("New label"); 871 | lblNewLabel_5.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\119061.jpg")); 872 | lblNewLabel_5.setBounds(0, 0, 1383, 49); 873 | panel_1.add(lblNewLabel_5); 874 | 875 | JLabel lblNewLabel_12 = new JLabel("New label"); 876 | lblNewLabel_12.setIcon(new ImageIcon("C:\\Users\\Jasmine\\Pictures\\Saved Pictures\\2277.jpg")); 877 | lblNewLabel_12.setBounds(0, 49, 1370, 20); 878 | frame.getContentPane().add(lblNewLabel_12); 879 | 880 | 881 | btnViewOwner.addActionListener(new ActionListener() { 882 | public void actionPerformed(ActionEvent e) { 883 | panel_2.removeAll(); 884 | panel_2.add(panel_6); 885 | panel_2.repaint(); 886 | panel_2.revalidate(); 887 | 888 | 889 | 890 | 891 | DefaultTableModel tb1 = new DefaultTableModel (0,0); 892 | 893 | tb1.addColumn("Sl No"); 894 | tb1.addColumn("ID"); 895 | tb1.addColumn("NAME"); 896 | tb1.addColumn("GENDER"); 897 | tb1.addColumn("DOB"); 898 | tb1.addColumn("ADDRESS"); 899 | tb1.addColumn("PHONE NUMBER"); 900 | tb1.addColumn("LICENSE NUMBER"); 901 | tb1.addColumn("USERNAME"); 902 | tb1.addColumn("PASSWORD"); 903 | tb1.addColumn("DELETE"); 904 | 905 | 906 | 907 | Object rowtb1[] = new Object[11]; 908 | 909 | JTable table_1 = new JTable(); 910 | table_1.setFont(new Font("Times New Roman", Font.BOLD, 17)); 911 | table_1.setBorder(new LineBorder(Color.LIGHT_GRAY,2)); 912 | table_1.setAlignmentX(Component.RIGHT_ALIGNMENT); 913 | table_1.setBackground(Color.PINK); 914 | table_1.setForeground(Color.WHITE); 915 | table_1.setRowHeight(50); 916 | 917 | 918 | 919 | scrollPane_1.setColumnHeaderView(table_1); 920 | 921 | table_1.setModel(tb1); 922 | 923 | table_1.getColumn("DELETE").setCellRenderer(new ButtonRenderer()); 924 | table_1.getColumn("DELETE").setCellEditor( 925 | new ButtonEditor(new JCheckBox())); 926 | scrollPane_1.setViewportView(table_1); 927 | 928 | 929 | 930 | 931 | tb1.getDataVector().removeAllElements(); 932 | tb1.fireTableDataChanged(); 933 | 934 | 935 | try 936 | { 937 | Class.forName("com.mysql.jdbc.Driver"); 938 | Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 939 | 940 | 941 | 942 | PreparedStatement ps = conn.prepareStatement("select * from owner_details where status='0'"); 943 | 944 | ResultSet rs = (ResultSet) ps.executeQuery(); 945 | int i = 0; 946 | 947 | while(rs.next()) { 948 | String slno="slno"; 949 | String id= rs.getString("id"); 950 | String name= rs.getString("own_name"); 951 | String gender= rs.getString("own_gend"); 952 | String dob= rs.getString("own_dob"); 953 | String address= rs.getString("own_add"); 954 | String phone= rs.getString("own_phn"); 955 | String license=rs.getString("own_lice"); 956 | String uname=rs.getString("user"); 957 | String pass=rs.getString("passw"); 958 | 959 | 960 | 961 | 962 | 963 | //tb1.addRow(new Object[] {"id",id, name, gender, dob, address, phone, license, uname, pass}); 964 | 965 | rowtb1[0]=slno; 966 | rowtb1[1]=id; 967 | rowtb1[2]=name; 968 | rowtb1[3]=gender; 969 | rowtb1[4]=dob; 970 | rowtb1[5]=address; 971 | rowtb1[6]=phone; 972 | rowtb1[7]=license; 973 | rowtb1[8]=uname; 974 | rowtb1[9]=pass; 975 | rowtb1[10]="Delete"; 976 | 977 | 978 | 979 | 980 | tb1.addRow(rowtb1); 981 | scrollPane_1.setViewportView(table_1); 982 | 983 | i++; 984 | } 985 | } 986 | catch(Exception ex) 987 | { 988 | ex.printStackTrace(); 989 | } 990 | 991 | 992 | 993 | 994 | } 995 | }); 996 | 997 | 998 | 999 | btnSubmit.addActionListener(new ActionListener() { 1000 | public void actionPerformed(ActionEvent arg0) { 1001 | 1002 | String oname=textField.getText(); 1003 | String dob=textField_2.getText(); 1004 | String Addr=textArea.getText(); 1005 | String Phn=textField_1.getText(); 1006 | String Lice=textField_3.getText(); 1007 | String Usname=textField_9.getText(); 1008 | String Passwd=textField_10.getText(); 1009 | 1010 | String qual = " "; 1011 | 1012 | // If condition to check if jRadioButton2 is selected. 1013 | if (rdbtnMale.isSelected()) { 1014 | 1015 | qual = "Male"; 1016 | } 1017 | 1018 | else if (rdbtnFemale.isSelected()) { 1019 | 1020 | qual = "Female"; 1021 | } 1022 | else { 1023 | 1024 | qual = "NO Button selected"; 1025 | } 1026 | if(textField.getText().isEmpty()||textField_2.getText().isEmpty()||textArea.getText().isEmpty()||textField_1.getText().isEmpty()||textField_3.getText().isEmpty()||textField_9.getText().isEmpty()||textField_10.getText().isEmpty()) 1027 | 1028 | { 1029 | if(textField.getText().isEmpty()) { 1030 | errorname.setText("*enter valid name"); 1031 | } 1032 | if(textField.getText().isEmpty()) { 1033 | errordob.setText("*fill the field "); 1034 | 1035 | } 1036 | if(textArea.getText().isEmpty()) { 1037 | errorad.setText("*enter the address"); 1038 | } 1039 | if(textField_1.getText().isEmpty()) { 1040 | errorph.setText("*enter the phone no:"); 1041 | } 1042 | if(textField_3.getText().isEmpty()) { 1043 | errorli.setText("*enter the license no:"); 1044 | } 1045 | } 1046 | else 1047 | { 1048 | try 1049 | { 1050 | Class.forName("com.mysql.jdbc.Driver"); 1051 | Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 1052 | Statement st=con.createStatement(); 1053 | int j=st.executeUpdate("insert into owner_details(own_name,own_gend,own_dob,own_add,own_phn,own_lice,user,passw) values('"+oname+"','"+qual+"','"+dob+"','"+Addr+"','"+Phn+"','"+Lice+"','"+Usname+"','"+Passwd+"')"); 1054 | 1055 | 1056 | JOptionPane.showMessageDialog(null,"REGISTRATION SUCCESSFUL"); 1057 | } 1058 | 1059 | catch(Exception e) 1060 | { 1061 | System.out.println(e); 1062 | e.printStackTrace(); 1063 | } 1064 | } 1065 | textField.setText(""); 1066 | textField_2.setText(""); 1067 | textArea.setText(""); 1068 | textField_1.setText(""); 1069 | textField_3.setText(""); 1070 | textField_9.setText(""); 1071 | textField_10.setText(""); 1072 | G1.clearSelection(); 1073 | 1074 | Refresh(); 1075 | 1076 | } 1077 | 1078 | private void Refresh() { 1079 | // TODO Auto-generated method stub 1080 | 1081 | } 1082 | }); 1083 | 1084 | 1085 | } 1086 | } 1087 | 1088 | 1089 | 1090 | 1091 | @SuppressWarnings("serial") 1092 | class ButtonRenderer extends JButton implements TableCellRenderer { 1093 | 1094 | public ButtonRenderer() { 1095 | setOpaque(true); 1096 | } 1097 | 1098 | public Component getTableCellRendererComponent(JTable table_4, Object value, 1099 | boolean isSelected, boolean hasFocus, int row, int column) { 1100 | if (isSelected) { 1101 | setForeground(table_4.getSelectionForeground()); 1102 | setBackground(table_4.getSelectionBackground()); 1103 | } else { 1104 | setForeground(table_4.getForeground()); 1105 | setBackground(UIManager.getColor("Button.background")); 1106 | } 1107 | setText((value == null) ? "" : value.toString()); 1108 | return this; 1109 | } 1110 | } 1111 | 1112 | 1113 | 1114 | @SuppressWarnings("serial") 1115 | class ButtonEditor extends DefaultCellEditor { 1116 | protected JButton button; 1117 | 1118 | private String label; 1119 | 1120 | private boolean isPushed; 1121 | 1122 | public ButtonEditor(JCheckBox checkBox) { 1123 | super(checkBox); 1124 | button = new JButton(); 1125 | button.setOpaque(true); 1126 | button.addActionListener(new ActionListener() { 1127 | public void actionPerformed(ActionEvent e) { 1128 | //table update code should be write here 1129 | fireEditingStopped(); 1130 | } 1131 | }); 1132 | } 1133 | 1134 | public Component getTableCellEditorComponent(JTable table_4, Object value, 1135 | boolean isSelected, int row, int column) { 1136 | if (isSelected) { 1137 | button.setForeground(table_4.getSelectionForeground()); 1138 | button.setBackground(table_4.getSelectionBackground()); 1139 | } else { 1140 | button.setForeground(table_4.getForeground()); 1141 | button.setBackground(table_4.getBackground()); 1142 | } 1143 | @SuppressWarnings("unused") 1144 | Object label1 = (value == null) ? "" : value.toString(); 1145 | // label=Integer.toString(table_4.getSelectedRow()); 1146 | 1147 | int selctrow = table_4.getSelectedRow(); 1148 | label = (String) table_4.getValueAt(selctrow, 1); 1149 | 1150 | // label= data.toString(); 1151 | button.setText("Accepted"); 1152 | isPushed = true; 1153 | return button; 1154 | } 1155 | 1156 | public Object getCellEditorValue() { 1157 | if (isPushed) { 1158 | 1159 | 1160 | System.out.println(label); 1161 | 1162 | JOptionPane.showMessageDialog(button, label); 1163 | 1164 | 1165 | Statement smt=null; 1166 | String st="1"; 1167 | try 1168 | { 1169 | Class.forName("com.mysql.jdbc.Driver"); 1170 | Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 1171 | 1172 | 1173 | 1174 | String sql="UPDATE owner_details SET status='"+st+"' WHERE id='"+label+"' "; 1175 | smt=con.createStatement(); 1176 | @SuppressWarnings("unused") 1177 | int i=smt.executeUpdate(sql); 1178 | 1179 | 1180 | } 1181 | catch(Exception ex) 1182 | { 1183 | System.out.println(ex); 1184 | } 1185 | 1186 | 1187 | 1188 | } 1189 | isPushed = false; 1190 | return new String("Accepted"); 1191 | } 1192 | 1193 | public boolean stopCellEditing() { 1194 | isPushed = false; 1195 | return super.stopCellEditing(); 1196 | } 1197 | 1198 | protected void fireEditingStopped() { 1199 | super.fireEditingStopped(); 1200 | } 1201 | } 1202 | 1203 | @SuppressWarnings("serial") 1204 | class ButtonRendererrej extends JButton implements TableCellRenderer { 1205 | 1206 | public ButtonRendererrej() { 1207 | setOpaque(true); 1208 | } 1209 | 1210 | public Component getTableCellRendererComponent(JTable table_4, Object value, 1211 | boolean isSelected, boolean hasFocus, int row, int column) { 1212 | if (isSelected) { 1213 | setForeground(table_4.getSelectionForeground()); 1214 | setBackground(table_4.getSelectionBackground()); 1215 | } else { 1216 | setForeground(table_4.getForeground()); 1217 | setBackground(UIManager.getColor("Button.background")); 1218 | } 1219 | setText((value == null) ? "" : value.toString()); 1220 | return this; 1221 | } 1222 | } 1223 | 1224 | 1225 | 1226 | @SuppressWarnings("serial") 1227 | class ButtonEditorrej extends DefaultCellEditor { 1228 | protected JButton button; 1229 | 1230 | private String label; 1231 | 1232 | private boolean isPushed; 1233 | 1234 | public ButtonEditorrej(JCheckBox checkBox) { 1235 | super(checkBox); 1236 | button = new JButton(); 1237 | button.setOpaque(true); 1238 | button.addActionListener(new ActionListener() { 1239 | public void actionPerformed(ActionEvent e) { 1240 | //table update code should be write here 1241 | 1242 | fireEditingStopped(); 1243 | } 1244 | }); 1245 | } 1246 | 1247 | public Component getTableCellEditorComponent(JTable table_4, Object value, 1248 | boolean isSelected, int row, int column) { 1249 | if (isSelected) { 1250 | button.setForeground(table_4.getSelectionForeground()); 1251 | button.setBackground(table_4.getSelectionBackground()); 1252 | } else { 1253 | button.setForeground(table_4.getForeground()); 1254 | button.setBackground(table_4.getBackground()); 1255 | } 1256 | @SuppressWarnings("unused") 1257 | Object label1 = (value == null) ? "" : value.toString(); 1258 | // label=Integer.toString(table_4.getSelectedRow()); 1259 | 1260 | 1261 | int selctrow = table_4.getSelectedRow(); 1262 | label = (String) table_4.getValueAt(selctrow, 1); 1263 | 1264 | // label= data.toString(); 1265 | button.setText("Rejected"); 1266 | isPushed = true; 1267 | return button; 1268 | } 1269 | 1270 | public Object getCellEditorValue() { 1271 | if (isPushed) { 1272 | 1273 | 1274 | System.out.println( "reject " +label); 1275 | 1276 | JOptionPane.showMessageDialog(null, label + " reject"); 1277 | 1278 | 1279 | //Connection con=null; 1280 | Statement smt=null; 1281 | String st="1"; 1282 | try 1283 | { 1284 | Class.forName("com.mysql.jdbc.Driver"); 1285 | Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root",""); 1286 | 1287 | 1288 | String sql="UPDATE vehicle SET status='"+st+"' WHERE id='"+label+"' "; 1289 | smt=con.createStatement(); 1290 | @SuppressWarnings("unused") 1291 | int i=smt.executeUpdate(sql); 1292 | 1293 | 1294 | } 1295 | catch(Exception ex) 1296 | { 1297 | System.out.println(ex); 1298 | } 1299 | 1300 | 1301 | 1302 | } 1303 | isPushed = false; 1304 | return new String("Rejected"); 1305 | 1306 | } 1307 | 1308 | public boolean stopCellEditing() { 1309 | isPushed = false; 1310 | return super.stopCellEditing(); 1311 | } 1312 | 1313 | protected void fireEditingStopped() { 1314 | super.fireEditingStopped(); 1315 | } 1316 | } 1317 | 1318 | 1319 | 1320 | 1321 | --------------------------------------------------------------------------------