Guest User

sukhdeep login

a guest
Jan 7th, 2018
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.12 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. public class Login implements ActionListener  {
  6.     private JFrame f;
  7.     private JTextField tf,tf1;
  8.     private JLabel user,pass,emd;
  9.     private JButton b,bn;
  10.     private JCheckBox cb;
  11.  
  12.     private Login()  {
  13.         f=new JFrame();
  14.         f.setSize(400,400);
  15.         f.setTitle("Login Frame");
  16.         f.setLayout(null);
  17.         f.getContentPane().setBackground(Color.ORANGE);
  18.         f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  19.        
  20.         /* For button */
  21.         b=new JButton("Login");
  22.         b.setBounds(140,270,80,40);
  23.         f.add(b);
  24.  
  25.         bn=new JButton("Sign up");
  26.         bn.setBounds(40,270,80,40);
  27.         f.add(bn);
  28.        
  29.         /* For Textfield */
  30.         tf=new JTextField();
  31.         tf.setBounds(100,85,160,20);
  32.         f.add(tf);
  33.  
  34.         tf1=new JTextField();
  35.         tf1.setBounds(100,135,160,20);
  36.         f.add(tf1);
  37.  
  38.         JPasswordField pf = new JPasswordField();
  39.         pf.setEchoChar('*');
  40.         pf.setBounds(100,185,160,20);
  41.         f.add(pf);
  42.  
  43.         cb = new JCheckBox("Remember me",false);
  44.         cb.setBounds(30,220,150,50);
  45.         cb.setBackground(Color.ORANGE);
  46.         f.add(cb);
  47.        
  48.         /*For Label */
  49.         user=new JLabel("Username : ");
  50.         user.setBounds(20,80,80,30);
  51.         f.add(user);
  52.  
  53.         emd=new JLabel("E-mail ID");
  54.         emd.setBounds(20,130,80,30);
  55.         f.add(emd);
  56.  
  57.         pass=new JLabel("Password : ");
  58.         pass.setBounds(20,180,80,30);
  59.         f.add(pass);
  60.  
  61.         f.setVisible(true);
  62.  
  63.         b.addActionListener(this);
  64.         bn.addActionListener(this);
  65.     }
  66.  
  67.     public void actionPerformed(ActionEvent e)  {
  68.         if(e.getSource()==b)  {
  69.             JOptionPane.showMessageDialog(f,"Your account is succesfully logged in");
  70.         }
  71.         else if(e.getSource()==bn)   {
  72.             JOptionPane.showMessageDialog(f,"Your account is succesfully signed up");
  73.         }
  74.  
  75.     }
  76.     public static void main(String[] args)  {
  77.         new Login();
  78.     }
  79. }
Add Comment
Please, Sign In to add comment