Program: 77214
Project: 77214
Buggy source:
/** 
 * Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic. Not all look and feels may support this. A value of -1 indicates either there is no mnemonic, the mnemonic character is not contained in the string, or the developer does not wish the mnemonic to be displayed. <p> The value of this is updated as the properties relating to the mnemonic change (such as the mnemonic itself, the text...). You should only ever have to call this if you do not wish the default character to be underlined. For example, if the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A' to be decorated, as 'Save <u>A</u>s', you would have to invoke <code>setDisplayedMnemonicIndex(5)</code> after invoking <code>setDisplayedMnemonic(KeyEvent.VK_A)</code>.
 * @since 1.4
 * @param index Index into the String to underline
 * @exception IllegalArgumentException will be thrown if <code>index</codeis >= length of the text, or < -1
 * @beaninfo bound: true attribute: visualUpdate true description: the index into the String to draw the keyboard character mnemonic at
 */
public void setDisplayedMnemonicIndex(int index) throws IllegalArgumentException {
  int oldValue=mnemonicIndex;
  if (index == -1) {
    mnemonicIndex=-1;
  }
 else {
    String text=getText();
    int textLength=(text == null) ? 0 : text.length();
    if (index < -1 || index >= textLength) {
      throw new IllegalArgumentException("String_Node_Str" + index);
    }
  }
  mnemonicIndex=index;
  firePropertyChange("String_Node_Str",oldValue,index);
  if (index != oldValue) {
    revalidate();
    repaint();
  }
}

Fixed version (ground truth):
/** 
 * Provides a hint to the look and feel as to which character in the text should be decorated to represent the mnemonic. Not all look and feels may support this. A value of -1 indicates either there is no mnemonic, the mnemonic character is not contained in the string, or the developer does not wish the mnemonic to be displayed. <p> The value of this is updated as the properties relating to the mnemonic change (such as the mnemonic itself, the text...). You should only ever have to call this if you do not wish the default character to be underlined. For example, if the text was 'Save As', with a mnemonic of 'a', and you wanted the 'A' to be decorated, as 'Save <u>A</u>s', you would have to invoke <code>setDisplayedMnemonicIndex(5)</code> after invoking <code>setDisplayedMnemonic(KeyEvent.VK_A)</code>.
 * @since 1.4
 * @param index Index into the String to underline
 * @exception IllegalArgumentException will be thrown if <code>index</code>is &gt;= length of the text, or &lt; -1
 * @beaninfo bound: true attribute: visualUpdate true description: the index into the String to draw the keyboard character mnemonic at
 */
public void setDisplayedMnemonicIndex(int index) throws IllegalArgumentException {
  int oldValue=mnemonicIndex;
  if (index == -1) {
    mnemonicIndex=-1;
  }
 else {
    String text=getText();
    int textLength=(text == null) ? 0 : text.length();
    if (index < -1 || index >= textLength) {
      throw new IllegalArgumentException("String_Node_Str" + index);
    }
  }
  mnemonicIndex=index;
  firePropertyChange("String_Node_Str",oldValue,index);
  if (index != oldValue) {
    revalidate();
    repaint();
  }
}