Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Keyboard commands in swing

  Asked By: Nicole    Date: Jul 08    Category: Java    Views: 824
  

Im a little stuck with my current swing project. I would like to be
able to press a single button on the keyboard, and have that press trigger
actionPerformed.

--What I have tried:
I have looked at setMnemonic, but would prefer to not have to use alt, or have
the action key letter underlined.

I have looked at setAccelerator, but would like to have it independant from
menu items

I have looked at keyListener/Typed/Pressed/Released, but would prefer have it
independant from any textField/Areas


--What I am looking for:
Option 1:
user presses F2, actionPerformed is notified

Option 2:
user presses 'b', the letter 'b' key is linked to a JButton, which gets
"doClick()ed", which notifies actionPerformed as if it had been mouse clicked
normally


If this is possible, any ideas would be greatly appreciated. :) Thanks so much
for the space.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Keyboard commands in swing Or get search suggestion and latest updates.




Tagged: