daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Apr 27th, 2016 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5.  
  6. public class LoginNew extends JFrame{
  7.  
  8.     String username1 = "staff";
  9.     String password1 = "staff";
  10.     String username2 = "Manager";
  11.     String password2 = "Managaer";
  12.     String username3 = "Admin";
  13.     String password3 = "Admin";
  14.     JPanel a, b, c;
  15.     JTextField tf1, tf2;
  16.     JLabel l1,l2;
  17.     JButton b1;
  18.  
  19.     public static void main(String[]s){
  20.         LoginNew now = new LoginNew();
  21.         JFrame frame = new JFrame();
  22.     }
  23.  
  24.     public LoginNew(){
  25.         setTitle("NewLogin");
  26.         setSize(700,300);
  27.         setLayout(new FlowLayout(FlowLayout.CENTER));
  28.         a = new JPanel();
  29.         b = new JPanel();
  30.         c = new JPanel();
  31.         tf1 = new JTextField(20);
  32.         tf2 = new JTextField(20);
  33.         l1 = new JLabel("Username:");
  34.         l2 = new JLabel("Password:");
  35.         b1 = new JButton("Login");
  36.         b1.addActionListener(new LoginListener());
  37.         a.add(l1);
  38.         a.add(tf1);
  39.         b.add(l2);
  40.         b.add(tf2);
  41.         c.add(b1);
  42.         add(a);
  43.         add(b);
  44.         add(c);
  45.         setVisible(true);
  46.     }
  47.     public class LoginListener implements ActionListener {
  48.         public void actionPerformed(ActionEvent event){
  49.             if(username1.equals(tf1.getText())){
  50.                 if(password1.equals(tf2.getText())){
  51.                     Main now = new Main();
  52.                 }else{
  53.                 if(username2.equals(tf1.getText())) {
  54.                         if (password2.equals(tf2)) {
  55.                             Manager now = new Manager();
  56.                         }
  57.                     }
  58.             }
  59.                 }else{
  60.                 if (username3.equals(tf1.getText())){
  61.                     if (password3.equals(tf2.getText())) {
  62.                         Manager now = new Manager ();
  63.                     }
  64.                 }
  65.                     {JOptionPane.showMessageDialog(null, "Error in username or password!");
  66.                     }
  67.                 }
  68.         }
  69.     }
  70.  
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top