This week's book giveaway is in the JavaScript forum.
We're giving away four copies of JavaScript Promises Essentials and have Rami Sarieddine on-line!
See this thread for details.
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 JavaScript Promises Essentials this week in the JavaScript 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