01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.sample.mail.client;
17:
18: import com.google.gwt.user.client.ui.Button;
19: import com.google.gwt.user.client.ui.ClickListener;
20: import com.google.gwt.user.client.ui.DialogBox;
21: import com.google.gwt.user.client.ui.HTML;
22: import com.google.gwt.user.client.ui.KeyboardListener;
23: import com.google.gwt.user.client.ui.VerticalPanel;
24: import com.google.gwt.user.client.ui.Widget;
25:
26: /**
27: * A simple example of an 'about' dialog box.
28: */
29: public class AboutDialog extends DialogBox {
30:
31: public AboutDialog() {
32: // Use this opportunity to set the dialog's caption.
33: setText("About the Mail Sample");
34:
35: // Create a VerticalPanel to contain the 'about' label and the 'OK' button.
36: VerticalPanel outer = new VerticalPanel();
37:
38: // Create the 'about' text and set a style name so we can style it with CSS.
39:
40: HTML text = new HTML(
41: "This sample application demonstrates the "
42: + "construction of a complex user interface using GWT's built-in "
43: + "widgets. Have a look at the code to see how easy it is to build "
44: + "your own apps!");
45: text.setStyleName("mail-AboutText");
46: outer.add(text);
47:
48: // Create the 'OK' button, along with a listener that hides the dialog
49: // when the button is clicked.
50: outer.add(new Button("Close", new ClickListener() {
51: public void onClick(Widget sender) {
52: hide();
53: }
54: }));
55:
56: setWidget(outer);
57: }
58:
59: @Override
60: public boolean onKeyDownPreview(char key, int modifiers) {
61: // Use the popup's key preview hooks to close the dialog when either
62: // enter or escape is pressed.
63: switch (key) {
64: case KeyboardListener.KEY_ENTER:
65: case KeyboardListener.KEY_ESCAPE:
66: hide();
67: break;
68: }
69:
70: return true;
71: }
72: }
|