Mnemonics in multi-lingual application

From: Morten Alver (morten_at_invalid.no)
Date: 10/26/04


Date: Tue, 26 Oct 2004 16:17:10 +0200

I have a Swing application which lacks mnemonic keys for menu items, and
I would like to correct this. I know how to set mnemonics for Actions,
but the problem is that my application can display in several languages
- meaning that the mnemonic keys need to be set according to the
translated names of menu items. All string literals are read from
resource files.

I wonder what is the best way of "automating" the setting of proper
mnemonic keys. One method I can think of is to specify the names like
"&File" and "Save&As" in the resource file, where the & would signify
that the following letter should be used as mnemonic. This would require
a wrapper for all Actions to sort out the correct letter and remove the
& before setting the name, but should work pretty well.

I'm just wondering if there is a better way of doing this, or if I am
reinventing the wheel. I expect that this is a fairly common problem, so
maybe there is some standard method for it that I haven't found?

--
Morten