aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to fire event automatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to fire event automatically" Watch "how to fire event automatically" New topic
Author

how to fire event automatically

Govinda Reddy
Greenhorn

Joined: Apr 07, 2006
Posts: 7
using swing i developed one login screen which contains ok button, cancel button and two text boxes for username and password.i am hardcoded username and password.i want to login with out mouseclick on the OK button.
In ActionPerformed method i am checking username and password. in my case loginSuccess() method returns always true.

public void actionPerformed(ActionEvent e)
{
String command=e.getActionCommand();

if(command.equalsIgnoreCase("OK")){
if(loginSuccess(){
executeApplication();
}
}

if(command.equalsIgnoreCase("Cancel"))
{
closeDialog();
}

}

how to execute actionPerformed() method without clicking on ok button.

please help me how to solve this problem.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
This forum is meant for SCJP. It would be better if you posted this in our Swing forum.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Barry Gaunt:
This forum is meant for SCJP. It would be better if you posted this in our Swing forum.

Moving to the Swing forum.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> how to execute actionPerformed() method without clicking on ok button.

set the OK button as the default
getRootPane().setDefaultButton(okButton);
Cp Baherwani
Ranch Hand

Joined: May 13, 2005
Posts: 41
doClick (inherited from AbstractButton)
public void doClick()
Programmatically perform a "click". This does the same thing as if the user had pressed and released the button.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to fire event automatically
 
Similar Threads
How to recognize the ActionEvent in a FocusLost method??
Login to a website
how to fire event automatically
trying to do a loop
how to connect to MS-Access from jsp