Reputation: 63
I am writing an eclipse plugin and I am using MessageDialog.openQuestion to pop up a question. The default answer is "Yes" but I want it to be "no". how do I do that?
Upvotes: 3
Views: 209
Reputation: 579
Try to change the defaultIndex attribute of the MessageDialog constructor.
(Give a look at the docs)
Upvotes: 0
Reputation: 111142
You can't do that using the openQuestion
method. Instead you will have to construct the MessageDialog
using one of the constructors:
MessageDialog dialog = new MessageDialog(shell, "title", null, "message",
MessageDialog.QUESTION, 1, IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL);
int buttonPressed = dialog.open();
The 1
is the index of the default button.
Upvotes: 2