Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

binding keys for use of buttons  RSS feed

 
Sancho Xavier
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,

I am having a problem binding keys to buttons in netbeans. I have an app that has a textfield that gets input from a series of 8 buttons. i want to map the numpad to these buttons ONLY when the textfield is the focus. so far I have implemented a rough KeyPressed listener that filters VK_NUMPADX through an if statement, but this is problematic. First and foremost, the button i press is also added to the textfield, i.e. if i map VK_NUMPAD1 to essentially paste "Hello", the textfield reads Hello1. Secondly, I have simply copy-pasted the contents of each button's action performed method into the if statements, which seems to be too brute force... how do i call the buttonActionPerformed method directly within this Keypressed method??

I hope i am clear enough to elicit a response thanks for your time and help!
 
Bartek Myszkowski
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i call the buttonActionPerformed method directly within this Keypressed method??
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!