| Author |
Press ENTER and ignit activate the button
|
Peter Primrose
Ranch Hand
Joined: Sep 10, 2004
Posts: 755
|
|
Hi all, Say I have a text field (search) and a button ("Get It"). the user simply put info in the jtextfield and intuitively he presses ENTER to proceed. how do i do that? I tried getIt.getRootPane().setDefaultButton(getIt); but i get a java.lang.NullPointerException I don't know how to get the root frame :-( any idea how to solve it? thanks
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
|
One way is to add an actionListener to your JTextField and have it call the same method your JButton's actionListener calls.
|
 |
 |
|
|
subject: Press ENTER and ignit activate the button
|
|
|