0

I am trying to use JFace Messagedialog.openInformation dialog, and my message string contains an ampersand '&' character. The ampersand is not displayed when the dialog is opened. Through trial and error, I have found that if I double the ampersand to && in the string, then it will display.

Escaping the & within the string has no effect.

Obviously, this is not the case if I write the string to system.out; so it is not a problem with String itself.

I am looking for some documentation on why this occurs.

GLNN.LRSN
  • 56
  • 1
  • 9

2 Answers2

1

You can use LegacyActionTools.escapeMnemonics(message) to escape the mnemonics in the situation when they should be displayed.

Krzysztof Słowiński
  • 6,239
  • 8
  • 44
  • 62
0

& is used to identify mnemonic accelerators for controls ... so it's possible that the text you are passing to the MessageDialog.openInformation method is being parsed by the same logic.

I haven't dug into the SWT code much, but I can't find a specific place where it is handling the '&' character, so it might be happening at the OS level.

David G
  • 3,940
  • 1
  • 22
  • 30