Add Teacher Details
Add Teacher Details
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.util.Random;
public class AddTeacherDetails extends JFrame implements ActionListener
{
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15;
JButton bt1,bt2;
JTextField tf1,tf2,tf3,tf4,tf5,tf6,tf7,tf8,tf9,tf10,tf11,tf12,tf13,tf14;
JFrame f;
JPasswordField pf1;
public AddTeacherDetails()
{
f=new JFrame("Add New Teacher Details");
f.setBackground(Color.WHITE);
f.setLayout(null);
l1=new JLabel();
l1.setBounds(0,0,840,600);
l1.setLayout(null);
ImageIcon img=new
ImageIcon(ClassLoader.getSystemResource("School_Management_System/Icons/
AddTeacher.jpg"));
Image i1=img.getImage().getScaledInstance(840, 600,Image.SCALE_SMOOTH );
ImageIcon img1=new ImageIcon(i1);
l1.setIcon(img1);
l2=new JLabel("Add Teacher Details for Signup");
l2.setBounds(230,50,500,50);
l2.setFont(new Font("Arial",Font.BOLD,30));
l2.setForeground(new Color(8,161,92));
l1.add(l2);
f.add(l1);
l3=new JLabel("Name");
l3.setBounds(50,150,150,30);
l3.setFont(new Font("Arial",Font.BOLD,20));
l3.setForeground(Color.DARK_GRAY);
l1.add(l3);
tf1=new JTextField();
tf1.setBounds(200,150,150,30);
l1.add(tf1);
l4=new JLabel("Username");
l4.setBounds(450,150,200,30);
l4.setFont(new Font("Arial",Font.BOLD,20));
l4.setForeground(Color.DARK_GRAY);
l1.add(l4);
tf2=new JTextField();
tf2.setBounds(600,150,150,30);
l1.add(tf2);
l5=new JLabel("Password");
l5.setBounds(50,200,150,30);
l5.setFont(new Font("Arial",Font.BOLD,20));
l5.setForeground(Color.DARK_GRAY);
l1.add(l5);
pf1=new JPasswordField();
pf1.setBounds(200,200,150,30);
l1.add (pf1);
l6=new JLabel("Email");
l6.setBounds(450,200,200,30);
l6.setFont(new Font("Arial",Font.BOLD,20));
l6.setForeground(Color.DARK_GRAY);
l1.add(l6);
tf3=new JTextField();
tf3.setBounds(600,200,150,30);
l1.add(tf3);
l7=new JLabel("Father Name");
l7.setBounds(50,250,140,30);
l7.setFont(new Font("Arial",Font.BOLD,20));
l7.setForeground(Color.DARK_GRAY);
l1.add(l7);
tf4=new JTextField();
tf4.setBounds(200,250,150,30);
l1.add(tf4);
l8=new JLabel("Phone");
l8.setBounds(450,250,100,30);
l8.setFont(new Font("Arial",Font.BOLD,20));
l8.setForeground(Color.DARK_GRAY);
l1.add(l8);
tf5=new JTextField();
tf5.setBounds(600,250,150,30);
l1.add(tf5);
l9=new JLabel("Qualification");
l9.setBounds(50,300,160,30);
l9.setFont(new Font("Arial",Font.BOLD,20));
l9.setForeground(Color.DARK_GRAY);
l1.add(l9);
tf6=new JTextField();
tf6.setBounds(200,300,150,30);
l1.add(tf6);
l10=new JLabel("City");
l10.setBounds(450,300,100,30);
l10.setFont(new Font("Arial",Font.BOLD,20));
l10.setForeground(Color.DARK_GRAY);
l1.add(l10);
tf7=new JTextField();
tf7.setBounds(600,300,150,30);
l1.add(tf7);
l11=new JLabel("Gender");
l11.setBounds(50,350,100,30);
l11.setFont(new Font("Arial",Font.BOLD,20));
l11.setForeground(Color.DARK_GRAY);
l1.add(l11);
tf8=new JTextField();
tf8.setBounds(200,350,150,30);
l1.add(tf8);
l12=new JLabel("Blood Group");
l12.setBounds(450,350,140,30);
l12.setFont(new Font("Arial",Font.BOLD,20));
l12.setForeground(Color.DARK_GRAY);
l1.add(l12);
tf9=new JTextField();
tf9.setBounds(600,350,150,30);
l1.add(tf9);
l13=new JLabel("D.O.B");
l13.setBounds(450,400,100,30);
l13.setFont(new Font("Arial",Font.BOLD,20));
l13.setForeground(Color.DARK_GRAY);
l1.add(l13);
tf10=new JTextField();
tf10.setBounds(600,400,150,30);
l1.add(tf10);
l14=new JLabel("Teaching Exp.");
l14.setBounds(50,400,150,30);
l14.setFont(new Font("Arial",Font.BOLD,20));
l14.setForeground(Color.DARK_GRAY);
l1.add(l14);
tf11=new JTextField();
tf11.setBounds(200,400,150,30);
l1.add(tf11);
bt1=new JButton("Submit");
bt1.setBounds(200,500,150,30);
bt2=new JButton("Cancel");
bt2.setBounds(450,500,150,30);
bt1.setForeground(Color.WHITE);
bt2.setForeground(Color.BLACK);
bt1.setBackground(Color.BLACK);
bt2.setBackground(new Color(191,247,161));
bt1.addActionListener(this);
bt2.addActionListener(this);
l1.add(bt1);
l1.add(bt2);
f.setVisible(true);
f.setSize(840,600);
f.setLocation(300, 100);
f.setResizable(false); }
public void actionPerformed(ActionEvent ae)
{ if(ae.getSource()==bt1)
{ String name=tf1.getText();
String username=tf2.getText();
String password=pf1.getText();
String email=tf3.getText();
String fathe_name=tf4.getText();
String phone=tf5.getText();
String qualification=tf6.getText();
String city=tf7.getText();
String gender=tf8.getText();
String blood=tf9.getText();
String dob=tf10.getText();
String exp=tf11.getText();
Random r = new Random();
String tec_id=""+Math.abs(r.nextInt()% 10000000);
try
{
ConnectionClass obj=new ConnectionClass();
}
catch (Exception ex)
{
ex.printStackTrace(); }}
if(ae.getSource()==bt2)
{
f.setVisible(false);
}
} public static void main(String[] args)
{ new AddTeacherDetails().setVisible(true); }}