KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > client > ui > PushButton


1 /*
2  * Copyright 2006 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
17 package com.google.gwt.user.client.ui;
18
19 /**
20  * A normal push button with custom styling.
21  *
22  * <p>
23  * <img class='gallery' SRC='PushButton.png'/>
24  * </p>
25  *
26  * <h3>CSS Style Rules</h3>
27  * <ul class="css">
28  * <li>.gwt-PushButton-up/down/up-hovering/down-hovering/up-disabled/down-disabled {.html-face}</li>
29  * </ul>
30  *
31  * <p>
32  * <h3>Example</h3> {@example com.google.gwt.examples.PushButtonExample}
33  * </p>
34  */

35 public class PushButton extends CustomButton {
36
37   private static final String JavaDoc STYLENAME_DEFAULT = "gwt-PushButton";
38
39   {
40     setStyleName(STYLENAME_DEFAULT);
41   }
42
43   /**
44    * Constructor for <code>PushButton</code>.
45    */

46   public PushButton() {
47     super();
48   }
49
50   /**
51    * Constructor for <code>PushButton</code>.
52    *
53    * @param upImage image for the default(up) face of the button
54    */

55   public PushButton(Image upImage) {
56     super(upImage);
57   }
58
59   /**
60    * Constructor for <code>PushButton</code>. The supplied image is used to
61    * construct the default face of the button.
62    *
63    * @param upImage image for the default (up) face of the button
64    * @param listener the click listener
65    */

66   public PushButton(Image upImage, ClickListener listener) {
67     super(upImage, listener);
68   }
69
70   /**
71    * Constructor for <code>PushButton</code>.
72    *
73    * @param upImage image for the default(up) face of the button
74    * @param downImage image for the down face of the button
75    */

76   public PushButton(Image upImage, Image downImage) {
77     super(upImage, downImage);
78   }
79
80   /**
81    * Constructor for <code>PushButton</code>.
82    *
83    * @param upImage image for the default(up) face of the button
84    * @param downImage image for the down face of the button
85    * @param listener clickListener
86    */

87   public PushButton(Image upImage, Image downImage, ClickListener listener) {
88     super(upImage, downImage, listener);
89   }
90
91   /**
92    * Constructor for <code>PushButton</code>. The supplied text is used to
93    * construct the default face of the button.
94    *
95    * @param upText the text for the default (up) face of the button.
96    */

97   public PushButton(String JavaDoc upText) {
98     super(upText);
99   }
100
101   /**
102    * Constructor for <code>PushButton</code>. The supplied text is used to
103    * construct the default face of the button.
104    *
105    * @param upText the text for the default (up) face of the button
106    * @param listener the click listener
107    */

108   public PushButton(String JavaDoc upText, ClickListener listener) {
109     super(upText, listener);
110   }
111
112   /**
113    * Constructor for <code>PushButton</code>.
114    *
115    * @param upText the text for the default (up) face of the button
116    * @param downText the text for down face of the button
117    */

118   public PushButton(String JavaDoc upText, String JavaDoc downText) {
119     super(upText, downText);
120   }
121
122   /**
123    * Constructor for <code>PushButton</code>.
124    *
125    * @param upText the text for the default (up) face of the button
126    * @param downText the text for down face of the button
127    * @param listener the click listener
128    */

129   public PushButton(String JavaDoc upText, String JavaDoc downText, ClickListener listener) {
130     super(upText, downText, listener);
131   }
132
133   protected void onClick() {
134     setDown(false);
135     super.onClick();
136   }
137   
138   protected void onClickCancel() {
139     setDown(false);
140   }
141
142   protected void onClickStart() {
143     setDown(true);
144   }
145 }
146
Popular Tags