Please i need help with My Login prog that can enable two categories of people to login that is the administrator and a user below is my code snipet bcos i am stucked.

import java.util.* ;
import java.awt.* ;
import java.awt.event.* ;
import javax.swing.*;

public class HeartLandLogin extends JPanel implements ActionListener 
{

JLabel lb1,lb2;
JTextField  jtf;
JPasswordField jpf;
JButton  bt,exit;
LoginListener  cool;

public HeartLandLogin() 
    {

lb1 =  new  JLabel("User Name:");
lb2 =  new  JLabel("PassWord:");
jtf=  new  JTextField(15);
jpf =  new  JPasswordField(15);
bt  =  new  JButton("LOGIN");
exit  =  new  JButton("Exit");
setLayout(new FlowLayout());
add(lb1);
add(jtf);       
add(lb2);       
add(jpf);       
add(bt);        
bt.addActionListener(this); 
exit.addActionListener(this);

}
public void addLoginListener(LoginListener cool) 
{
 this.cool = cool;
}


LoginEvent user;
public void fireLoginEvent(LoginEvent user) 
{

    cool.validateLogin(user);

}

public void actionPerformed(ActionEvent ae) 
    {
        if (ae.getSource()==bt) 
        {

String current1=jtf.getText();
String current2=new String(jpf.getPassword());
user = new LoginEvent(bt,current1,current2);
fireLoginEvent(user);
        }
    }
}





import java.util.*;
public class LoginEvent extends EventObject 
{
    public String username; 
public String password; 
public LoginEvent(Object objt,String username,String password)  
{            

super(objt);        
this.username=username;     
this.password=password; 
}
}

import java.util.* ;
public interface LoginListener extends EventListener 
{
    public void validateLogin(LoginEvent user);
}

import java.awt.* ;
import java.awt.event.* ;
import javax.swing.*;

public class LoginValidator extends JFrame implements LoginListener
{
HeartLandLogin  plain;
public LoginValidator() 
    {
        super("Login Form");

        plain = new HeartLandLogin();


        getContentPane().add(plain);


        plain.addLoginListener(this);
    }
    public void validateLogin(LoginEvent user) 
    {
        String current1=user.username;
        String current2=user.password;

        if(current1.equals(current2))

            JOptionPane.showMessageDialog(this,new 
                    String("Invalid user Login Details"));

        {


                this.dispose();
                HeartLandHome hlh = new HeartLandHome();
                hlh.setSize(1200,750);
                hlh.show();
                hlh.addWindowListener(new WindowAdapter()
            {
            public void windowClosing(WindowEvent t)
            {
                setEnabled(true);
            }
            });
}
}

    public static void main(String args[]) 
    {
        LoginValidator user = new LoginValidator();
        user.setSize(1100, 750);
        user.setVisible(true);
    }

}

Please i need all the help i can get..

Recommended Answers

All 4 Replies

Please, use [code] [/code] tags around any code that you post - after 22 posts here you should be aware of that by now.

Edit: You can put code tags in your post above by clicking "Edit This Post", "Go Advanced", highlighting the code part and clicking the "#" (Wrap code tags around text) toolbar button.

What questions do you have about the code? You're going to need to be a little more specific than "I need help".

where are user/admin credentials stored?

where are user/admin credentials stored?

in sql server2000

sql server2000

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.