aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Press ENTER and ignit activate the button Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Press ENTER and ignit activate the button" Watch "Press ENTER and ignit activate the button" New topic
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Press ENTER and ignit activate the button
 
Similar Threads
Sign in button
Keypressing on console or Dos prompt
coding for response to enter button on keyboard
KeyListener for a button?
SET A BUTTON AS "DEFAULT"