Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Binding key presses to specific actions

 
Anonymous
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 Blackdown.org) 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.

 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!