Create an automated regression test for JDK-4138746
Issue:
In the following example (and similarly with other components) you cannot specify the correct character to underline:
JLabel label = new JLabel ("Save As...");
label.setDisplayedMnemonic ('A');
The 'A' in 'As' should be underlined (that's the intention at least), but the 'a' in 'Save' is what gets underlined.
The problem (aside from the lack of an API to specify exactly what should be underlined) is in the javax.swing.plaf.basic.BasicGraphicUtils drawString method which underlines the first character (upper OR lowercase) that matches the mnemonic character.
Fix:
A new property "displayedMnemonicIndex" is introduced
in classes AbstractButton and JLabel. It tells which
character to underline. So for example to underline
the capital 'A' in 'Save As', one should call:
setMnemonic('A');
setDisplayedMnemonicIndex(5);
Testing:
Tested in Mach5 10 times per platform and got all Pass.