01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.samples.explorer.client;
09:
10: import net.mygwt.ui.client.Events;
11: import net.mygwt.ui.client.Style;
12: import net.mygwt.ui.client.event.BaseEvent;
13: import net.mygwt.ui.client.event.Listener;
14: import net.mygwt.ui.client.event.SelectionListener;
15: import net.mygwt.ui.client.widget.Button;
16: import net.mygwt.ui.client.widget.ButtonBar;
17: import net.mygwt.ui.client.widget.MessageBox;
18: import net.mygwt.ui.client.widget.WidgetContainer;
19: import net.mygwt.ui.client.widget.layout.FlowLayout;
20:
21: public class MessageBoxPage extends Page {
22:
23: protected void createWidget(WidgetContainer container) {
24: final MessageBox info = new MessageBox(Style.ICON_INFO,
25: Style.MODAL | Style.OK);
26: info.setText("Information");
27: info.setMessage("The sky is blue");
28:
29: final MessageBox question = new MessageBox(Style.ICON_QUESTION,
30: Style.YES_NO);
31: question.setText("Question");
32: question
33: .setMessage("Are you sure you want to set your hair on fire?");
34: question.addListener(Events.Close, new Listener() {
35: public void handleEvent(BaseEvent be) {
36: if (be.type == Events.Close) {
37: Button btn = question.getButtonPressed();
38: System.out.println(btn.getText());
39: }
40: }
41: });
42:
43: final MessageBox alert = new MessageBox(Style.ICON_ERROR,
44: Style.OK);
45: alert.setText("Alert");
46: alert.setMessage("Your hair is on fire!!!");
47:
48: ButtonBar buttonBar = new ButtonBar();
49: buttonBar.add(new Button("Info", new SelectionListener() {
50: public void widgetSelected(BaseEvent be) {
51: info.open();
52: }
53: }));
54: buttonBar.add(new Button("Question", new SelectionListener() {
55: public void widgetSelected(BaseEvent be) {
56: question.open();
57: }
58: }));
59: buttonBar.add(new Button("Alert", new SelectionListener() {
60: public void widgetSelected(BaseEvent be) {
61: alert.open();
62: }
63: }));
64:
65: container.setLayout(new FlowLayout(10));
66: container.add(buttonBar);
67: }
68:
69: }
|