Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.*;
- import java.awt.*;
- import java.applet.*;
- import javax.swing.*;
- import javax.swing.JOptionPane;
- import javax.swing.JWindow;
- import java.lang.*;
- import java.util.Scanner;
- public class sa extends JFrame implements ActionListener {
- JButton b1;
- JButton b3, b4;
- Container con = getContentPane();
- JPanel panel;
- JLabel fu, ad, re, ren, reg, age;
- JTextField ful, addr, ref, refn, agg;
- JCheckBox c = new JCheckBox("Show Password");
- Choice ch = new Choice();
- CheckboxGroup gp = new CheckboxGroup();
- Checkbox male = new Checkbox("Male", gp, false);
- Checkbox female = new Checkbox("Female", gp, false);
- Checkbox other = new Checkbox("Other", gp, false);
- JLabel gender = new JLabel("Gender");
- JPasswordField pass;
- JButton b5, b6;
- JTextField user;
- JPasswordField ps, pw;
- JTextField username;
- sa()
- {
- Scanner iput = new Scanner(System.in);
- age = new JLabel("Age");
- fu= new JLabel("Enter Full Name");
- ad= new JLabel("Enter Adress");
- re= new JLabel("Who Refers you to join the company?");
- ren= new JLabel("Enter Referral ID number");
- ful= new JTextField(15);
- ful.addActionListener(this);
- addr= new JTextField(15);
- addr.addActionListener(this);
- ref = new JTextField(15);
- refn = new JTextField(15);
- reg = new JLabel(" REGISTER ");
- agg = new JTextField(10);
- //proceed button
- b1 = new JButton("Proceed");
- b1.setBackground(Color.GREEN);
- //JButton Action
- b1.addActionListener(this);
- //Jpanel
- panel = new JPanel();
- con.setLayout(new BorderLayout());
- //
- panel.add(reg);
- //full name
- panel.add(fu);
- panel.add(ful);
- //address
- panel.add(ad);
- panel.add(addr);
- //gender
- panel.add(gender);
- panel.add(male);
- panel.add(female);
- panel.add(other);
- //age
- panel.add(age);
- panel.add(agg);
- //referral
- panel.add(re);
- panel.add(ref);
- //
- panel.add(ren);
- panel.add(refn);
- //button
- panel.add(b1);
- con.add(panel);
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- }
- public void actionPerformed(ActionEvent e){
- Object source = e.getSource();
- String fname=ful.getText();
- String nn=addr.getText();
- String nnn=ref.getText();
- String nmn=refn.getText();
- String agr=agg.getText();
- if(source==b1){
- if(fname.isEmpty()){
- JOptionPane.showMessageDialog(null, "You didn't enter your name");
- }
- else if(nn.isEmpty()){
- JOptionPane.showMessageDialog(null, "Please enter your address");
- }
- else if(agr.isEmpty()){
- JOptionPane.showMessageDialog(null, "Please Verify Age");
- }
- else if(nnn.isEmpty()){
- JOptionPane.showMessageDialog(null, "Please fill refferal's name");
- }
- else if(nmn.isEmpty()){
- JOptionPane.showMessageDialog(null, "Please enter referral's ID number");
- }
- else{
- JFrame frame;
- JPanel pan;
- JLabel l, lp, lpr;
- Checkbox ch;
- frame = new JFrame("Acct Fill up");
- frame.setVisible(true);
- frame.setBounds(450, 100, 175, 275);
- frame.setVisible(true);
- frame.setResizable(false);
- pan = new JPanel();
- l = new JLabel("Enter User ID");
- lp = new JLabel("Enter Password");
- lpr = new JLabel("Verify Password");
- user = new JTextField(10);
- ps = new JPasswordField(10);
- pw = new JPasswordField(10);
- b3 = new JButton("Register");
- b4 = new JButton("Cancel");
- //username
- pan.add(l);
- pan.add(user);
- //password
- pan.add(lp);
- pan.add(ps);
- //verify
- pan.add(lpr);
- pan.add(pw);
- pan.add(b3);
- b3.setBackground(Color.ORANGE);
- pan.add(b4);
- b4.setBackground(Color.RED);
- b4.addActionListener(this);
- frame.add(pan);
- Object src = e.getSource();
- b3.addActionListener(this);
- }
- }
- String us = user.getText();
- String zx = ps.getText();
- String cx= pw.getText();
- String cv = ps.getText();
- String vc = pw.getText();
- int length = 0;
- int numCount = 0;
- int capCount = 0;
- int x;
- String result;
- if(source==b3){
- if(us.isEmpty()){
- JOptionPane.showMessageDialog(null,"Please Confirm User ID");
- }
- else if(zx.isEmpty()){
- JOptionPane.showMessageDialog(null, "Please Enter Password");
- }
- for(x=0; x<cv.length(); x++){
- if(cv.charAt(x)>=47 && cv.charAt(x)<=58 || (cv.charAt(x) >= 65 && cv.charAt(x)<=91) || (cv.charAt(x)>=97 && cv.charAt(x) <= 122)){
- }
- else{
- JOptionPane.showMessageDialog(null, "Please make stronger password");
- }
- if((cv.charAt(x) > 47 && cv.charAt(x) < 58)){
- numCount++;
- }
- if((cv.charAt(x) > 64 && cv.charAt(x)<91)){
- capCount++;
- }
- length = (x+1);
- }
- if(numCount < 2){
- JOptionPane.showMessageDialog(null, "Not enough Numbers in password");
- }
- else if(capCount < 2){
- JOptionPane.showMessageDialog(null, "Not enough Capital letters in password");
- }
- else if(length < 8){
- JOptionPane.showMessageDialog(null, "Password too short, Please make Stronger Password");
- JOptionPane.showMessageDialog(null, "must be atleast 8 characters long");
- }
- else if(cx.isEmpty()){
- JOptionPane.showMessageDialog(null, "Please Verify your Password");
- }
- //your problem...
- else if(cx!=zx){
- JOptionPane.showMessageDialog(null, "Please Verify your Password");
- }
- else{
- JOptionPane.showMessageDialog(null, "Registered Successfully!");
- JOptionPane.showConfirmDialog(null, "Do you want to login now?");
- JWindow window = new JWindow();
- window.getContentPane().add(new JLabel("", new ImageIcon("3.png"),SwingConstants.CENTER));
- window.setBounds(450, 100, 320, 240);
- window.setSize(650,400);
- window.setVisible(true);
- try{
- Thread.sleep(5000);
- }
- catch(InterruptedException ex){}
- window.dispose();
- JFrame frame = new JFrame("Login");
- frame.setVisible(true);
- frame.setBounds(450, 100, 185,265);
- frame.setResizable(false);
- JLabel l, la;
- l = new JLabel("UserID");
- la = new JLabel("Password");
- JPanel p =new JPanel();
- user = new JTextField(15);
- pass = new JPasswordField(15);
- pass.setEchoChar('•');
- pass.addActionListener(this);
- user.addActionListener(this);
- b5 = new JButton("Login");
- b6 = new JButton("Cancel");
- b5.addActionListener(this);
- b5.addActionListener(this);
- p = new JPanel();
- //loigin
- p.add(l);
- p.add(user);
- p.add(la);
- p.add(pass);
- p.add(c);
- p.add(b5);
- p.add(b6);
- b5.setBackground(Color.GREEN);
- b6.setBackground(Color.ORANGE);
- frame.add(p);
- c.addActionListener(this);
- b5.addActionListener(this);
- b6.addActionListener(this);
- }
- }
- if(source==b5){
- String uname=user.getText();
- String psd=pass.getText();
- String meme=user.getText();
- String memee=pass.getText();
- String userr=user.getText();
- String passw=ps.getText();
- String passs=pw.getText();
- String name=ful.getText();
- if(uname.equals(userr) && psd.equals(passw) && psd.equals(passs)){
- JOptionPane.showMessageDialog(null, "Welcome " + name + "!");
- JFrame f1;
- f1 = new JFrame("WELCOME!");
- f1.setVisible(true);
- f1.setSize(5000,5000);
- f1.setResizable(false);
- }
- else if(meme.equals("Administrator") && memee.equals("123")){
- JOptionPane.showMessageDialog(null, "Welcome back Admin");
- JButton bn;
- JFrame f2;
- JLabel la,al;
- f2 = new JFrame("WELCOME!");
- f2.setVisible(true);
- f2.setSize(5000,5000);
- f2.setResizable(false);
- la = new JLabel("Administrator", SwingConstants.CENTER);
- f2.add(la);
- }
- else{
- JOptionPane.showMessageDialog(null, "Invalid Username or Password");
- }
- }
- else if(source==b6){
- System.exit(0);
- }
- else if(source==b4){
- System.exit(0);
- }
- else{
- }
- if(c.isSelected()){
- pass.setEchoChar((char)0);
- }
- else{
- pass.setEchoChar('•');
- }
- }
- public static void main(String[]args){
- JWindow window = new JWindow();
- window.getContentPane().add(new JLabel(" ", new ImageIcon("3.png"),SwingConstants.CENTER));
- window.setBounds(450, 100, 320, 240);
- window.setSize(600,398);
- window.setVisible(true);
- try{
- Thread.sleep(0);
- }
- catch(InterruptedException e){}
- window.dispose();
- sa frm = new sa();
- frm.setVisible(true);
- frm.setResizable(false);
- frm.setTitle("Aim Global");
- frm.setBounds(500,150,222,375);
- //END
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement