}
}));
buttonBar.add(new Button("Prompt", new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
final MessageBox box = MessageBox.prompt("Name", "Please enter your name:");
box.addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) {
Info.display("MessageBox", "You entered '{0}'", new Params(be.getValue()));
}
});
}
}));
buttonBar.add(new Button("Multiline Prompt", new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
MessageBox box = MessageBox.prompt("Address", "Please enter your address:", true);
box.addCallback(new Listener<MessageBoxEvent>() {
public void handleEvent(MessageBoxEvent be) {
String v = Format.ellipse(be.getValue(), 80);
Info.display("MessageBox", "You entered '{0}'", new Params(v));
}
});
}
}));
buttonBar.add(new Button("Yes/No/Cancel", new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
MessageBox box = new MessageBox();
box.setButtons(MessageBox.YESNOCANCEL);
box.setIcon(MessageBox.QUESTION);
box.setTitle("Save Changes?");
box.addCallback(l);
box.setMessage("You are closing a tab that has unsaved changes. Would you like to save your changes?");
box.show();
}
}));
buttonBar.add(new Button("Progress", new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
final MessageBox box = MessageBox.progress("Please wait", "Loading items...",
"Initializing...");
final ProgressBar bar = box.getProgressBar();
final Timer t = new Timer() {
float i;
@Override
public void run() {
bar.updateProgress(i / 100, (int) i + "% Complete");
i += 5;
if (i > 105) {
cancel();
box.close();
Info.display("Message", "Items were loaded", "");
}
}
};
t.scheduleRepeating(500);
}
}));
buttonBar.add(new Button("Wait", new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
final MessageBox box = MessageBox.wait("Progress",
"Saving your data, please wait...", "Saving...");
Timer t = new Timer() {
@Override
public void run() {
Info.display("Message", "Your fake data was saved", "");
box.close();
}
};
t.schedule(5000);
}
}));