Sunday, January 13, 2013

♥♥♥ Login In Java ♥♥♥

import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
 
 class Login extends JFrame implements ActionListener
 {
  JButton SUBMIT;
  JButton Cancel;
  //JPanel panel;
  JLabel label1,label2;
  final JTextField  text1,text2;
   Login()
   {
 
   setLayout(null);
   label1 = new JLabel("Username:");
   label1.setFont(new Font("Lucida Fax",0,15));
   label1.setBounds(50,50,100,100);
  
  
   text1 = new JTextField(15);
   text1.setFont(new Font("Lucida Fax",0,15));
   text1.setBounds(150,85,170,30);

   label2 = new JLabel("Password:");
   label2.setFont(new Font("Lucida Fax",0,15));
   label2.setBounds(50,100,100,100);
  

   text2 = new JPasswordField(15);
   text2.setFont(new Font("Lucida Fax",0,15));
   text2.setBounds(150,135,170,30);
  
   SUBMIT=new JButton("SUBMIT");
   //SUBMIT.setFont(new Font("Lucida Fax",0,15));
   SUBMIT.setBounds(110,190,80,30);



   //SUBMIT.setFont(new Font("Lucida Fax",0,15));
   SUBMIT.setBounds(110,190,80,30);

   Cancel=new JButton("Cancel");
   Cancel.setBounds(220,190,80,30);
   Cancel.addActionListener(this);
  
  
  
   add(label1);
   add(text1);
   add(label2);
   add(text2);
   add(SUBMIT);
   add(Cancel);
   //add(panel,BorderLayout.CENTER);
   SUBMIT.addActionListener(this);
  
   setTitle("LOGIN FORM");
   }
  public void actionPerformed(ActionEvent ae)
   {
   String value1=text1.getText();
   String value2=text2.getText();
   if (value1.equals("Zaheer") && value2.equals("zaheer")) {
dispose();

}
if(ae.getSource()==Cancel)
{

System.exit(0);
}


}
 }
  class Start
 {
   public static void main(String arg[])
   {
   try
   {
   Login frame=new Login();
   frame.setSize(400,300);
   frame.setLocation(300,200);
   frame.setVisible(true);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   }
   catch(Exception e)
   {JOptionPane.showMessageDialog(null, e.getMessage());}
   }
 }

OUTPUT :
OUTPUT


No comments: