This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a frame that contains a panel with a button. How can I make it so that if the user presses enter, the button is automatically activated. If tried to no avail to requestFocus to the button. Thanks
You have to catch the keypress. And it depends on the element that has the focus how to do this. If fact, you should add a KeyListener to all elements that can possibly have the focus. The KeyListener should override the following methods: void keyPressed(KeyEvent e) Invoked when a key has been pressed. void keyReleased(KeyEvent e) Invoked when a key has been released. void keyTyped(KeyEvent e) Invoked when a key has In the method keyPressed you can then check for an enter to be pressed. HTH, Kris Philippaerts