Re: Overwrite what Keys do.
Quote:
Originally Posted by
Melawe
Hey guys,
I'm looking for a way to overwrite what happens when a key is pressed. For example, show an image rather than text, or ignore it. If there is a class that does it that would be great. But I'm also looking for something more low level(not native code :P)
If you're looking to do this at an O/S level (i.e. it happens in every application) you're going to have to "go native". If you're looking to do it in a single Java application, take a look at KeyListener
Re: Overwrite what Keys do.
I actually was reading that and the key bindings tutorial the other day. The problem with KeyListeners is I can't keep it from showing the text on the screen. What I want to do is, lets say, be able to type number "2" from the number row above the letters on the keyboard. But do something else when number "2" on the number pad is used.
I don't want to use native code because Java is the only programming language I know atm, if I use native code I will have code I can't maintain on my own.
Re: Overwrite what Keys do.
Quote:
Originally Posted by
Melawe
I actually was reading that and the key bindings tutorial the other day. The problem with KeyListeners is I can't keep it from showing the text on the screen. What I want to do is, lets say, be able to type number "2" from the number row above the letters on the keyboard. But do something else when number "2" on the number pad is used.
I don't want to use native code because Java is the only programming language I know atm, if I use native code I will have code I can't maintain on my own.
What you describe is exactly what KeyBindings and KeyListeners are for. I'm not sure what the problem you describe is...do you mean you have a TextComponent and wish the component respond in a way to certain key events other than editing the text component?
Re: Overwrite what Keys do.
Quote:
Originally Posted by
copeg
What you describe is exactly what KeyBindings and KeyListeners are for. I'm not sure what the problem you describe is...do you mean you have a TextComponent and wish the component respond in a way to certain key events other than editing the text component?
Hmm, the key bindings tutorial was a bit confusing, Ill give it another go and report back. Thanks.