HOW TO CREATE A SIMPLE LOGIN PAGE IN JAVA:
we can create a login page in java similar as other languages,but in java by default awt components are static that means it won't perform any operation thats why you have seen whenever you create Frame then we can't close the Frame. If we want to close a Frame then we press ctr+c.
If we want to create our Frame Dynamic the we should add components to Listeners because Listeners hold many methods and those methods are able to perform all operations.
So let's start to create simple static login page in java.
Inside the login page there are many components like user name,password, login Buttton etc.
import java.awt.*;
class loginpage
{
public static void main(String[] args)
{
Frame f=new Frame();
f.setVisible(true);
f.setSize(400,400);
f.setBackground(Color.RED);
f.setTitle("login page ");
f.setLayout(new FlowLayout());
Label l1=new Label("user name");
Label l2=new Label("password");
TextField tx1=new TextField(40);
TextField tx2=new TextField(40);
Button b=new Button("Login");
f.add(l1);
f.add(tx1);
f.add(l2);
f.add(tx2);
f.add(b);
}
}
Explanation : This is a simple login page and it is static ,so the login button won't able to perform because all components are static . If we want perform any operation so we can add Listeners.after connect the listeners your login page getting dynamic.
We also explain listeners in my next posts.