HorizontalPanel hPanel = new HorizontalPanel();
hPanel.setSpacing(10);
hPanel.add(new Button("Info", new ClickHandler() {
public void onClick(ClickEvent event) {
MessageBox.info("Info", "Permission is allowed", new MessageBoxListener() {
public void onMessageBoxClosed(MessageBox sender, ButtonType buttonClicked) {
//log("Closed message box");
}
}).show();
}
}));
hPanel.add(new Button("Alert", new ClickHandler() {
public void onClick(ClickEvent event) {
MessageBox.alert("Alert", "This document has not been saved", new MessageBoxListener() {
public void onMessageBoxClosed(MessageBox sender, ButtonType buttonClicked) {
//log("Closed message box");
}
}).show();
}
}));
hPanel.add(new Button("Error", new ClickHandler() {
public void onClick(ClickEvent event) {
MessageBox.error("Error", "An error has occurred", new MessageBoxListener() {
public void onMessageBoxClosed(MessageBox sender, ButtonType buttonClicked) {
//log("Closed message box");
}
}).show();
}
}));
hPanel.add(new Button("Confirm", new ClickHandler() {
public void onClick(ClickEvent event) {
MessageBox.confirm("Confirm", "Are you sure you want to do that?", new MessageBoxListener() {
public void onMessageBoxClosed(MessageBox sender, ButtonType buttonClicked) {
//log("Closed message box");
}
}).show();
}
}));
hPanel.add(new Button("Confirm/Cancel", new ClickHandler() {
public void onClick(ClickEvent event) {
MessageBox.confirm("Confirm", "Are you sure you want to do that?",
MessageBox.BTN_YES | MessageBox.BTN_NO | MessageBox.BTN_CANCEL,
new MessageBoxListener() {
public void onMessageBoxClosed(MessageBox sender, ButtonType buttonClicked) {
//log("Closed message box");
}
}).show();
}
}));
hPanel.add(new Button("Prompt", new ClickHandler() {
public void onClick(ClickEvent event) {
MessageBox.prompt("Prompt", "Please enter your name", new MessageBoxListener() {
public void onMessageBoxClosed(MessageBox sender, ButtonType buttonClicked) {
//Window.alert("You entered: " + sender.getText());
//log("Closed message box");
}
}).show();
}
}));
hPanel.add(new Button("Multiline Prompt", new ClickHandler() {
public void onClick(ClickEvent event) {
MessageBox.prompt("Prompt", "Please enter your name", true, new MessageBoxListener() {
public void onMessageBoxClosed(MessageBox sender, ButtonType buttonClicked) {
//Window.alert("You entered: " + sender.getText());
//log("Closed message box");
}
}).show();
}
}));
hPanel.add(new Button("Password", new ClickHandler() {
public void onClick(ClickEvent event) {
MessageBox.password("Password", "Please enter your password", new MessageBoxListener() {
public void onMessageBoxClosed(MessageBox sender, ButtonType buttonClicked) {
//Window.alert("You entered: " + sender.getText());
//log("Closed message box");
}
}).show();
}
}));
hPanel.add(new Button("Widget", new ClickHandler() {
public void onClick(ClickEvent event) {
ListBox lb = new ListBox();
lb.addItem("foo");
lb.addItem("bar");
lb.addItem("baz");
MessageBox.prompt("Any widget", "Please select one of the following items", lb, new MessageBoxListener() {
public void onMessageBoxClosed(MessageBox sender, ButtonType buttonClicked) {
//Window.alert("You entered: " + sender.getText());
//log("Closed message box");
}
}).show();