i have a ok and cancel button on screen.After i fill the values for all the fields, on press of enter key i want the ok button to get activated and corresponding operation for login button to be performed.can any one give a sample code or tip
Add an ActionListener (or FocusListener) to your textfields that keeps track of which textfields have been filled out (or accessed). Then have the listener enable the OK button. As far as using the Enter key to launch the OK function, you'll just need to add a KeyListener that checks with the other listener (above) to see if all the fields are done, and then calls the same code your normal OK button ActionListener does.
-Nate
P.S. - Red Goliath... Please re-register with a username that follows the Official JavaRanch UserName Convention. ( UserNames in the form "first name" + space + "last name", and no obviously fake names... ) Thanks! [This message has been edited by Nathan Pruett (edited December 19, 2001).]
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Vinod Venugopal
Ranch Hand
Joined: Dec 06, 2000
Posts: 148
posted
0
Add a keylistener to your textfield as below: loginTxt.addKeyListener( new KeyAdapter() { public void keyReleased(KeyEvent ke) { //enable /disable your buttons.. } });