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

Binding key presses to specific actions  RSS feed

Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there
I have a JTextField in my program . Upon the user pressing the backspace key , I wish to perform my own specific method, not the default one , which is to delete the previous character.
I get the Keymap JTextField.getKeyMap() and I bind my user defined backspace action to the backspace key
km.addActionForKeyStroke(KeyStroke.getKeyStroke (KeyEvent.VK_BACK_SPACE,0),myMethodHere)
Ok , here is the problem. The above code works *perfectly* fine on Windows NT , however when compiled and run this on a Linux Machine ( Redhat 6.1 running WMaker, Kernel 2.2 , Java 1.2 from it fails to work properly. When pressed the cursor actually does the *opposite* to what it is defined to do.
Has anyone come accross this problem before ? .
Any help would be greatly appreciated.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!