Configure Keys in Swing/AWT

Hey all,

I’m trying to have a Swing GUI to configure keys for 3079. It is looking like this will be rather ugly…

I found the AwtKeyInput class, which can convert between AWT codes and JME3 codes. However, is there any elegant solution to selecting & displaying keys? If I want to display the name of keys (e.g. “Tab” and “Enter”), I assume I need to write a large switch case to convert all characters to a pretty name? Seems like this would have been done before with an easier solution? Any suggestions?


Just remove the key_ prefix of the jme keys. e.g.: key_space.replace(“key_”, “”).

@glaucomardano said:
Just remove the *key_* prefix of the jme keys. e.g.: key_space.replace("key_", "").

Ummm... what are you talking about? Where does this magic key_space string come from? :)

There is a class I just noticed called KeyNames:

I don't know what it returns, though.
1 Like

But it doesn't work, because it's the name of the variable, it's not a string value xD. I'm drunk xD.
1 Like

[java] KeyNames kn = new KeyNames();

String str = kn.getName(KeyInput.KEY_RETURN);[/java]

And BAM, str is “Enter” – thanks guys!

@glaucomardano said:
I'm drunk xD.

It's funny... because I almost asked that. :)