/**
* Sets the text of a label including mnemonic. <br>
* Same functionality as
*
* @see setTextWithMnemonic
*
* @param label
* Label to handle
* @param text
* Displaytext, possibly including & for mnemonic specification
*/
/**
* Sets the text of a menu, menuitem, button or checkbox. If a & character
* is found, it is used to define the mnemonic. Else the text is set just as
* if the setText method of the component was called.
*
* @param component
* Menu, menuitem, button or checkbox to handle
* @param text
* Displaytext, possibly including & for mnemonic specification
*/
public static void setTextWithMnemonic( [[#variablef3cf480]] [[#variablef3c7300]], String text) {
// search for mnemonic
int index = text.indexOf("&");
if ((index != -1) && ((index + 1) < text.length())) {
// mnemonic found
// ...and not at the end of the string (which doesn't make sence)
char mnemonic = text.charAt(index + 1);
StringBuffer buf = new StringBuffer();
// if mnemonic is first character of this string
if (index == 0) {
buf.append(text.substring(1));
}
else {
buf.append(text.substring(0, index));
buf.append(text.substring(index + 1));
}
[[#variablef3c7300]].setText(buf.toString());
[[#variablef3c7300]]. [[#variablef3cf500]](mnemonic);
[[#variablef3c7300]].setDisplayedMnemonicIndex(index);
}
else {
[[#variablef3c7300]].setText(text);
}
}
|