0

I am working on a calculator and I am almost done. The last step I want to manage is to use the calculator with my numpad. My idea was to use Keylisteners but my problem is, anytime I press a key, it is always the same button which responds to all of the keys, because the focus is always on this button. When I click with my mouse on another button the focus is set on this one and now everytime I press a key, this button responds to all the keys.

My question is, how do I change the focus everytime I press a key?

  • you need know which button should have the focus next and then use grabFocus() executed on that button – XtremeBaumer May 16 '17 at 13:42
  • 1
    Possible duplicate of [JButton & Action & KeyBinding](http://stackoverflow.com/questions/13565900/jbutton-action-keybinding) – Frakcool May 16 '17 at 13:50
  • I am not sure if it is the same. He has got just one button. Isn't there a easy way to solve this problem? – Anton Sarg May 16 '17 at 17:42

0 Answers0