/** * Sets the text of the button whereby the first single occurence of the * character {@code '&'} is used to determine the next character as the * mnemonic for this button. * <p> * All single occurences of {@code '&'} are removed from the text * and all double occurences are replaced by a single {@code '&'} * before passing the result to the super classes implementation. * <p> * Note that if the resulting text is HTML, the index of the mnemonic * character is ignored and the look and feel will (if at all) highlight * the first occurence of the mnemonic character. */ @Override public void setText(final String text) { if (null != text) { final MnemonicText mt = new MnemonicText(text); super.setText(mt.toString()); if (0 <= mt.getMnemonicIndex()) { setMnemonic(mt.getMnemonic()); if (!mt.isHtmlText()) setDisplayedMnemonicIndex(mt.getMnemonicIndex()); } } else { super.setText(null); } } }
/** * Sets the text of the button whereby the first single occurence of the * character {@code '&'} is used to determine the next character as the * mnemonic for this button. * <p> * All single occurences of {@code '&'} are removed from the text * and all double occurences are replaced by a single {@code '&'} * before passing the result to the super classes implementation. * <p> * Note that if the resulting text is HTML, the index of the mnemonic * character is ignored and the look and feel will (if at all) highlight * the first occurence of the mnemonic character. */ @Override public void setText(final String text) { if (null != text) { final MnemonicText mt = new MnemonicText(text); super.setText(mt.toString()); if (0 <= mt.getMnemonicIndex()) { setMnemonic(mt.getMnemonic()); if (!mt.isHtmlText()) setDisplayedMnemonicIndex(mt.getMnemonicIndex()); } } else { super.setText(null); } } }