非 RCP SWT アプリにカスタム ボタン タイトルを追加したいと考えています。
MessageBox messageBox = new MessageBox(shell, SWT.ICON_WARNING | SWT.ABORT | SWT.RETRY | SWT.IGNORE);
messageBox.setText("Warning");
messageBox.setMessage("Save the changes before exiting?");
int buttonID = messageBox.open();
switch(buttonID) {
case SWT.YES:
// saves changes ...
case SWT.NO:
// exits here ...
break;
case SWT.CANCEL:
// does nothing ...
}
System.out.println(buttonID);
}
正常に動作しますが、ボタンのタイトルは「中止」、「再試行」、「無視」です 「上書き」、「名前の変更」、「キャンセル」などのカスタムボタンのタイトルが必要です。それはどのように行うことができますか?
助けてください。
** * 編集 * ** * ** * *
私も試しました
MessageDialog dialog = new MessageDialog(null, "Dangerous Activity", null,
"Are you sure you want to delete?", MessageDialog.CONFIRM,
new String[]{"Preview>", "Delete", "Cancel"}, 0)
{
protected void buttonPressed(int buttonId) {
setReturnCode(buttonId);
// close(); Call close for Delete or Cancel?
}};
ただし、MessageDialog ではアプリが RCP である必要があるため、パッケージをインポートする必要はありません。ヘルプ。