This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes setFocus in JButton is there any? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "setFocus in JButton is there any?" Watch "setFocus in JButton is there any?" New topic
Author

setFocus in JButton is there any?

Jan Michael Soan
Ranch Hand

Joined: Feb 08, 2003
Posts: 36
Hello;
I have made a password protection program, but after typing the password and pressing the enter button notting happens.
I need to press the Tab button on my key board and press spacebar so that it will run.
My purpose is to press the JButton after typing & pressing the enter button on my keyboard, to do that i need to do setFocus, but i dont know it in Java can anyone pls. help me.
Thanks and GodBless.
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

I am going to assume that you are using a JPasswordField or a JtextField for the password entry.
If so, you can just addActionListener to your Field and have it call the same method your JButton calls to perform the validation.
 
I agree. Here's the link: jrebel
 
subject: setFocus in JButton is there any?
 
Similar Threads
JTable input not correctly input-ted when a button is pressed
Keypressing on console or Dos prompt
Urgent! jtable get value when cell is edited
one key press
Compilation errors scrolling off the screen