Results 1 to 3 of 3
- 10-31-2010, 02:26 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 86
- Rep Power
- 0
disabling JFrame's response to spacebar
How can I get a JFrame to stop responding to the spacebar? I'm programming a video game and I want to use the spacebar for firing. I'm using key binding for all responses to key strokes. I just added the spacebar to my bindKeys() method and it didn't respond the same way the other keys did. I soon realized the reason is because the JFrame seems to have priority over the spacebar and it uses it to activate whichever component has the focus. I have a few buttons and I tested this by pressing tab and then seeing if the spacebar had a different response - and it did. I don't really need the JFrame to respond to the spacebar in this way, so I'm looking for a way to disable its responding to it. Is this possible?
- 10-31-2010, 06:11 AM #2
You can try setFocusable(false) for the buttons.
db
- 11-01-2010, 04:38 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 86
- Rep Power
- 0
Similar Threads
-
Automatic Content Assist (no CTRL+SPACEBAR)
By dnikolov in forum EclipseReplies: 3Last Post: 12-19-2011, 05:02 PM -
Disabling Buttons
By superpala in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 07-26-2010, 10:00 PM -
Disabling Bluetooth passkey
By lambi in forum Sun Java Wireless ToolkitReplies: 0Last Post: 12-29-2009, 01:33 PM -
Disabling a button at EOF
By dbashby in forum New To JavaReplies: 1Last Post: 03-10-2009, 02:37 PM -
disabling JButtons after win in TicTacToe
By noisepoet in forum New To JavaReplies: 1Last Post: 05-18-2007, 11:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks