TextWithMnemonic (@NotNull @Nls String text, char mnemonicChar) { if (mnemonicChar == 0) { return fromPlainText(text); } mnemonicChar = Character.toUpperCase(mnemonicChar); for (int i = 0; i < text.length(); i++) { if (Character.toUpperCase(text.charAt(i)) == mnemonicChar) { return new TextWithMnemonic(text, i, ""); } } int ellipsisLength = getEllipsisLength(text); String suffix = "(" + mnemonicChar + ")" + text.substring(text.length() - ellipsisLength); text = text.substring(0, text.length() - ellipsisLength); return new TextWithMnemonic(text, text.length() + 1, suffix); }