/*import the required packages*/
import java.awt. * ;
import java.awt.event. * ;
public class ValidateEvent extends EventObject implements ActionListener
public String username, password;
public ValidateEvent (Object o, String username, String password)
this.username = username;
this.password = password;
public interface ValidationListener extends EventListener
public void Validation (ValidateEvent val);
/* Display message */
JOptionPane.showMessageDialog ( this, new
string(“Please enter correct login details”) ;
String(“ You have entered the correct Login Details,Thank you”));
am tryin to create an event handler to display 1 of the above messages if the user enters wrong or correct details while login. Am i on the right track? aasssist please whare possible by giving examples in relation to what i am trying to do.PLEASE NOTE I AM NEW TO JAVA.
You may be over-complicating things perhaps unnecessarily. Are you sure that you want to create your own new EventObject-extending class and Listener class? Have you first tried using a tried-and-true ActionListener added to a button?
i hav worked with buttons b4,i am tryin to display a message if any of the conditions is met.can i get help on how i can do that.mayb a snipped showing how a dialog box can be shown
For a small listener like this, I would use an anonymous inner class as my ActionListener, and then when the button has been pressed, query the "this" object to see the state of the conditions, and based on this, display the appropriate dialog.
If you have to use a separate listener class, and you are using an MVC pattern then you could pass a reference of the current model to the listener and in the actionPerformed method ask the model its state and show a dialog based on the model's response. This of course is a more complex solution.