/** Sets the text for a JLabel. Mostly identical to Actions.setMenuText in openide. I believe the reason for the special handling of & as the last character has to do with the ja-locale. * Cut from the name '&' char. * @param item JLabel * @param text new label * @param useMnemonic if true and '&' char found in new text, next char is used * as Mnemonic. */ public static void setLabelText(JLabel item, String text, boolean useMnemonic) { int i = text.indexOf('&'); String newText = text; if (i < 0) { item.setText(text); if (useMnemonic) { item.setDisplayedMnemonic (0); } } else { if (i == (text.length() - 1)) { file://Ampersand is last characted, use first character as shortcut item.setText(text.substring(0, i)); if (useMnemonic) { item.setDisplayedMnemonic (0); } } else { item.setText(text.substring(0, i) + text.substring(i + 1)); if (useMnemonic) { item.setDisplayedMnemonic(text.charAt(i + 1)); } } } }