Login screen window - Coder's point

Monday, March 25, 2019

Login screen window


 import java.awt.*;   
 import java.awt.event.*;   
 public class AEvent  
 {   
   public static void main(String[] args)   
   {   
     Frame f=new Frame("Button Example");   
     TextField tf1=new TextField();   
     TextField tf2=new TextField();   
     tf2.setEchoChar('#');  
     tf1.setBounds(70,50, 150,20);   
     tf2.setBounds(70,100, 150,20);   
     Label la1=new Label("USERNAME");  
     la1.setBounds(0,50,150,20);  
     Label la2=new Label("PASSWoRD");  
     la2.setBounds(0,100,150,20);  
     Label la3=new Label();  
     Button b1=new Button("LOGIN");   
     b1.setBounds(50,150,60,30);   
     Button b2=new Button("RESET");  
     b2.setBounds(150,150,60,30);  
     la3.setBounds(250,150,150,20);  
     b1.addActionListener(new ActionListener()  
       {   
         public void actionPerformed(ActionEvent e)  
         {   
           // tf1.setText("Welcome to Javatpoint.");   
           // tf2.setText("Welcome to Javatpoint112.");  
           if(tf1.getText().equals("system") && tf2.getText().equals("system"))  
           {   la3.setText("Login Form - Valid user");  
             //        AEvent1 obj=new AEvent1();  
             //     obj.setVisible(true);  
           }  
           else  
             la3.setText("Login Form - Invalid user");  
         }   
       });   
     b2.addActionListener(new ActionListener()  
       {   
         public void actionPerformed(ActionEvent e)  
         {   
           tf1.setText("");   
           tf2.setText("");  
         }   
       });   
     f.add(b1);  
     f.add(tf1);  
     f.add(tf2);   
     f.add(la1);  
     f.add(la2);  
     f.add(b2);  
     f.add(la3);  
     f.setSize(400,400);   
     f.setLayout(null);   
     f.setVisible(true);    
   }   
 }   
OUTPUT :

No comments:

Post a Comment