Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class Login implements ActionListener {
- private JFrame f;
- private JTextField tf,tf1;
- private JLabel user,pass,emd;
- private JButton b,bn;
- private JCheckBox cb;
- private Login() {
- f=new JFrame();
- f.setSize(400,400);
- f.setTitle("Login Frame");
- f.setLayout(null);
- f.getContentPane().setBackground(Color.ORANGE);
- f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- /* For button */
- b=new JButton("Login");
- b.setBounds(140,270,80,40);
- f.add(b);
- bn=new JButton("Sign up");
- bn.setBounds(40,270,80,40);
- f.add(bn);
- /* For Textfield */
- tf=new JTextField();
- tf.setBounds(100,85,160,20);
- f.add(tf);
- tf1=new JTextField();
- tf1.setBounds(100,135,160,20);
- f.add(tf1);
- JPasswordField pf = new JPasswordField();
- pf.setEchoChar('*');
- pf.setBounds(100,185,160,20);
- f.add(pf);
- cb = new JCheckBox("Remember me",false);
- cb.setBounds(30,220,150,50);
- cb.setBackground(Color.ORANGE);
- f.add(cb);
- /*For Label */
- user=new JLabel("Username : ");
- user.setBounds(20,80,80,30);
- f.add(user);
- emd=new JLabel("E-mail ID");
- emd.setBounds(20,130,80,30);
- f.add(emd);
- pass=new JLabel("Password : ");
- pass.setBounds(20,180,80,30);
- f.add(pass);
- f.setVisible(true);
- b.addActionListener(this);
- bn.addActionListener(this);
- }
- public void actionPerformed(ActionEvent e) {
- if(e.getSource()==b) {
- JOptionPane.showMessageDialog(f,"Your account is succesfully logged in");
- }
- else if(e.getSource()==bn) {
- JOptionPane.showMessageDialog(f,"Your account is succesfully signed up");
- }
- }
- public static void main(String[] args) {
- new Login();
- }
- }
Add Comment
Please, Sign In to add comment