RFE: Setting text and mnemonic at once

This document describes the expected behaviour of the RFE 27009 implementation (named RFE: [I18N] All text & mnemonic as "An&ything").

The background

When developing easily i18zed applications there arise several problems around representing mnemonic keys:

The idea

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:

The solution and implementation details

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.


author: Maxym Mykhalchuk
last modified 11.08.2003
Draft, the history is available in issue 27009