This document describes the expected behaviour of the RFE 27009 implementation (named RFE: [I18N] All text & mnemonic as "An&ything").
When developing easily i18zed applications there arise several problems around representing mnemonic keys:
AbstractButton.displayedMnemonicIndex
,
that represents an index of a character, that the look and feel
should provide decoration for as representing the mnemonic
character.
mnemonic
to be some latin symbol
and then manually setting displayedMnemonicIndex
to, e.g. 6
.
displayedMnemonicIndex
in order
to get a nice-looking UI, so it tends to be ommited.
displayedMnemonicIndex
is error-prone.
It would be nice to set three properties of a button: text
,
mnemonic
and displayedMnemonicIndex
using only one string value, editable in NetBeans Form Editor.
It will solve many of i18n problems:
displayedMnemonicIndex
,
which (that's the real challenge ;-) ), which they don't need in English
version of an application.
displayedMnemonicIndex
.
The proposed solution is to use & symbol while editing text property to indicate that the next following letter will serve as mnemonic key.
Setting three properties at once and a lookup, which latin symbol
is to be set as (real) mnemonic, is then implemented via
a call of a method setLocalizedText
of a class org.openide.awt.Mnemonics
in NetBeans OpenAPIs.
This feature involves a non-standard extension of Swing APIs, that's why it's considered as non-recommended for general development, and will be:
In order to indicate, whether a particular form uses this non-standard extension or not, it's proposed to have a synthetic property "Generate Mnemonics code" for a top-level form container (e.g. JFrame) in "Code Generation" section.
It's also possible to set this property on a component basis, indicating that one specific component doesn't use such technique, or vice versa - while all the form is left untouched, the very one component is using it.
The mnemonics support can also be turned on in global options, then each new created form's "Generate mnemonics" is set to true.