KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > sample > mail > client > AboutDialog


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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("This sample application demonstrates the "
41         + "construction of a complex user interface using GWT's built-in "
42         + "widgets. Have a look at the code to see how easy it is to build "
43         + "your own apps!");
44     text.setStyleName("mail-AboutText");
45     outer.add(text);
46
47     // Create the 'OK' button, along with a listener that hides the dialog
48
// when the button is clicked.
49
outer.add(new Button("Close", new ClickListener() {
50       public void onClick(Widget sender) {
51         hide();
52       }
53     }));
54
55     setWidget(outer);
56   }
57
58   public boolean onKeyDownPreview(char key, int modifiers) {
59     // Use the popup's key preview hooks to close the dialog when either
60
// enter or escape is pressed.
61
switch (key) {
62       case KeyboardListener.KEY_ENTER:
63       case KeyboardListener.KEY_ESCAPE:
64         hide();
65         break;
66     }
67
68     return true;
69   }
70 }
71
Popular Tags