MessageBOX vaadin easy question

Hi Guys,

I am trying to use MessageBox vaadin addon on my application but I can’t find out which variable to test if user clicked on “Yes” or if clicked on “No” on a question Dialog.

Like in this code below. How do I continue from there to take actions when user click on yes or no.

MessageBox mb = new MessageBox(HausOverview.this.getWindow(),
“Are you sure?”,
MessageBox.Icon.QUESTION,
“Do you really want to continue?”,
new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, “Yes”),
new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, “No”));
mb.show();
});

Thank YOu

I can’t make it work properly I am trying to add a messagebox to a button event

here is my code

btnTest.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
MessageBox mb = new MessageBox(mainWindow.getWindow(),
“Are you sure?”,
MessageBox.Icon.QUESTION,
“Do you really want to continue?”,
new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, “Yes”),
new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, “No”));
mb.show(new EventListener() {
private static final long serialVersionUID = 1L;
public void buttonClicked(ButtonType buttonType) {
// System.out.println("This button was pressed: " + buttonType);
mainWindow.showNotification("This button was pressed: " + buttonType);
}

                @Override
                public void notificationHidden(VNotification.HideEvent event) {
                    
                }
            });
        }
    });

12833.png

Nevermind I was able to make it work

see the code:

btnTest.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
MessageBox mb = new MessageBox(mainWindow.getWindow(),
“Are you sure?”,
MessageBox.Icon.QUESTION,
“Do you really want to continue?”,
new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, “Yes”),
new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, “No”));
mb.show(new MessageBox.EventListener() {

                @Override
                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("This button was pressed: " + buttonType);
                    if (buttonType.toString() == "YES") {
                        mainWindow.showNotification("This button was pressed: " + buttonType);
                    } else {
                        mainWindow.showNotification("This button was pressed: " + buttonType);
                    }
                }
            });
        }
    });

Hi, is there a way to auto close the MessageBox add-on after a certain time…?