385 |
*/ |
*/ |
386 |
public void setDisplayedMnemonic(char mnemonic) |
public void setDisplayedMnemonic(char mnemonic) |
387 |
{ |
{ |
388 |
setDisplayedMnemonic((int) mnemonic); |
setDisplayedMnemonic((int) Character.toUpperCase(mnemonic)); |
389 |
} |
} |
390 |
|
|
391 |
/** |
/** |
399 |
} |
} |
400 |
|
|
401 |
/** |
/** |
402 |
* This method sets which character in the text will be the underlined |
* This method sets which character in the text will be the underlined |
403 |
* character. If the given index is -1, then this indicates that there is |
* character. If the given index is -1, then this indicates that there is |
404 |
* no mnemonic. If the index is less than -1 or if the index is equal to |
* no mnemonic. If the index is less than -1 or if the index is equal to |
405 |
* the length, this method will throw an IllegalArgumentException. |
* the length, this method will throw an IllegalArgumentException. |
410 |
* length. |
* length. |
411 |
*/ |
*/ |
412 |
public void setDisplayedMnemonicIndex(int newIndex) |
public void setDisplayedMnemonicIndex(int newIndex) |
413 |
throws IllegalArgumentException |
throws IllegalArgumentException |
414 |
{ |
{ |
415 |
if (newIndex < -1 || (text != null && newIndex >= text.length())) |
if (newIndex < -1 || (text != null && newIndex >= text.length())) |
416 |
throw new IllegalArgumentException(); |
throw new IllegalArgumentException(); |
417 |
|
|
418 |
if (text == null || text.charAt(newIndex) != displayedMnemonic) |
if (newIndex == -1 |
419 |
|
|| text == null |
420 |
|
|| text.charAt(newIndex) != displayedMnemonic) |
421 |
newIndex = -1; |
newIndex = -1; |
422 |
|
|
423 |
if (newIndex != displayedMnemonicIndex) |
if (newIndex != displayedMnemonicIndex) |
424 |
{ |
{ |
425 |
firePropertyChange(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY, |
int oldIndex = displayedMnemonicIndex; |
|
displayedMnemonicIndex, newIndex); |
|
426 |
displayedMnemonicIndex = newIndex; |
displayedMnemonicIndex = newIndex; |
427 |
|
firePropertyChange(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY, |
428 |
|
oldIndex, newIndex); |
429 |
} |
} |
430 |
} |
} |
431 |
|
|