A simple "yes/no" message

Answered

Hi,

 

I'd like to ask the user a simple yes or no question with a dialog. What is the simplest way to do this?

Thanks.

0
4 comments
Messages.showYesNoDialog(message, title, yesText, noText, Messages.getQuestionIcon())
2
Avatar
Permanently deleted user

Perfect, thank you Vladimir.

0

To my embarrassment, I can never remember the code myself and have to search in my plugin code where I know I used it before.

0

Looking at the code of Messages.showYesNoDialog, it just calls MessageDialogBuilder.yesNo. It looks like it might be there just for backwards compatibility or something. I wonder if it is better to call it directly?

import com.intellij.openapi.ui.MessageDialogBuilder;
...
final MessageDialogBuilder.YesNo dialogBuilder =
MessageDialogBuilder.yesNo(title, message)
.yesText(yesText)
.noText(noText)
.icon(Messages.getQuestionIcon());
boolean answer = dialogBuilder.guessWindowAndAsk();

 

0

Please sign in to leave a comment.