- // Setup the menu shortcut
- String newLabel = "";
- boolean foundAmp = false;
- boolean foundShortcut = false;
- int shortcutIdx = 0;
- for (int i = 0; i < label.length(); i++) {
- char c = label.charAt(i);
- if (c == '&') {
- if (foundAmp == true) {
- newLabel += '&';
- shortcutIdx++;
- } else {
- foundAmp = true;
- }
- } else {
- newLabel += c;
- if (foundAmp == true) {
- if (foundShortcut == false) {
- shortcut = c;
- foundAmp = false;
- foundShortcut = true;
- this.shortcutIdx = shortcutIdx;
- }
- } else {
- shortcutIdx++;
- }
- }
- }
- this.rawLabel = newLabel;
+ // Setup the menu shortcut
+ String newLabel = "";
+ boolean foundAmp = false;
+ boolean foundShortcut = false;
+ int scanShortcutIdx = 0;
+ for (int i = 0; i < label.length(); i++) {
+ char c = label.charAt(i);
+ if (c == '&') {
+ if (foundAmp) {
+ newLabel += '&';
+ scanShortcutIdx++;
+ } else {
+ foundAmp = true;
+ }
+ } else {
+ newLabel += c;
+ if (foundAmp) {
+ if (!foundShortcut) {
+ shortcut = c;
+ foundAmp = false;
+ foundShortcut = true;
+ shortcutIdx = scanShortcutIdx;
+ }
+ } else {
+ scanShortcutIdx++;
+ }
+ }
+ }
+ this.rawLabel = newLabel;
+ }
+
+ // ------------------------------------------------------------------------
+ // MnemonicString ---------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get the keyboard shortcut character.
+ *
+ * @return the highlighted character
+ */
+ public char getShortcut() {
+ return shortcut;