Mac OS X key bindings in Java
We've found out that our software does not follow all Mac conventions when it comes to keyboards shortcuts. This was a bit of a surprise, as everything has been done "by the book".
In Mac OS X, the common key binding for paste is Command-V. You don't have the Command key in other environments, where the Control key does the same job. For that reason, you should use java.awt.Tookit.getMenuShortcutKeyMask() when initialising accelerator keys for your menu bars. Then either Control or Command is used, depending on which is the convention in the given environment. This is documented in, e.g., Java Development Guide for Mac OS X:
So far so good. But what about pasting text into text boxes? JTextArea supports keyboards shortcuts directly. However it uses the Control convention on all platforms. There's no neat system to make it platform adaptable, but maybe we could take java.awt.Tookit.getMenuShortcutKeyMask() and use it to customise also JTextArea components (and similar)?
What you can do is to change key bindings for a single component, like your JTextArea. Doing this would give you a GUI where one text box uses a different convention than all the rest. Of course you can always create factory methods and use them everywhere so that all the components get initialised to use the customised key bindings. Then you would be creating your own small framework on top of the Swing framework. I want to use GUI frameworks, not to develop them.
We would need a way to globally change the key bindings. KeyStroke processing happens in two steps in the components: First InputMap is used to map the input event to an action key sort of thing, and then ActionMap to map that action key to an Action object. So far I haven't found a way to globally change input mappings. LookAndFeel has a set of promising methods (makeInputMap, makeKeyBindings...), but they are all static.
Another alternative is the old-schoolish JTextComponent keymap functionality (static methods addKeymap and getKeymap). However I have not been able to dig out the default Actions, so that they could be remapped to platform specific keys.
I am not saying that writing fully Mac friendly Java applications is impossible, but doing so would require quite a bit of hacking: A lot of work to produce code that is hard to maintain. How hard can it be to get one key mapping correct? Maybe I am missing something?