Can someone tell what to use to disable the enter key in a JTable? I switched over from JAVA 1.2.2 to JAVA 1.3.0 which I used the command "inventoryTable.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0))", which worked fine. But in JAVA 1.3.0, it is now obsolete. Any example would be helpful. Thanks in advance, Marc Bourdon
I already have a KeyListener for the JTable, but the default for the enter key is to do a skip to the next line. Each time I press the enter key, it skips the line and selects the other line under the one I wanted to select. Marc
When a method is deprecated, the API will almost always give information on what other methods to use instead. Sure enough, the API for unregisterKeyboardAction() does indeed contain relevant info. Looks like you can use getActionMap() or getInputMap() to retrieve the existing bindings, and then use the associated remove() methods to remove the appropriate key bindings. I'm not particularly familiar with these methods myself, so I can't say much more right now - but hopefully this gives you an idea what to look into. Study the APIs for details. Good luck!
Hi Jim, I did study the APIs for the InputMap to use the remove() but didn't get any success. But what I noticed when I press on the control key and press enter at the same time, it doesn't skip to the next line. Is there a way that I could assign the control key kinda pressed each time I press the enter in my JTable? Marc
Post by:autobot
Run away! Run away! Here, take this tiny ad with you:
a bit of art, as a gift, the permaculture playing cards