KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > html > OptGroup


1 /*
2  * ====================================================================
3  *
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if
22  * any, must include the following acknowlegement:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "The Jakarta Project", "Jakarta Element Construction Set",
29  * "Jakarta ECS" , and "Apache Software Foundation" must not be used
30  * to endorse or promote products derived
31  * from this software without prior written permission. For written
32  * permission, please contact apache@apache.org.
33  *
34  * 5. Products derived from this software may not be called "Apache",
35  * "Jakarta Element Construction Set" nor "Jakarta ECS" nor may "Apache"
36  * appear in their names without prior written permission of the Apache Group.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Apache Software Foundation. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57  */

58 package org.apache.ecs.html;
59
60 import org.apache.ecs.*;
61
62 /**
63     This class creates a &lt;OptGroup&gt; tag.
64
65     @version $Id: OptGroup.java,v 1.4 2003/04/27 09:22:12 rdonkin Exp $
66     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
67     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
68 */

69 public class OptGroup extends MultiPartElement implements Printable, FocusEvents, FormEvents, MouseEvents, KeyEvents
70 {
71
72     /**
73         Private initialization routine.
74     */

75     {
76         setElementType("optgroup");
77     }
78     
79     /**
80         Basic constructor. Use the set* methods to set the values
81         of the attributes.
82     */

83     public OptGroup()
84     {
85     }
86     
87     /**
88         Basic constructor. Use the set* methods to set the values
89         of the attributes.
90         
91         @param label sets the attribute LABEL=""
92     */

93     public OptGroup(String JavaDoc label)
94     {
95         setLabel(label);
96     }
97
98     /**
99         Basic constructor. Use the set* methods to set the values
100         of the attributes.
101         
102         @param label sets the attribute LABEL=""
103         @param disabled sets the attribute DISABLED=
104     */

105     public OptGroup(String JavaDoc label, boolean disabled)
106     {
107         setLabel(label);
108         setDisabled(disabled);
109     }
110
111     /**
112         Sets the LABEL="" attribute
113         @param label the LABEL="" attribute
114     */

115     public OptGroup setLabel(String JavaDoc label)
116     {
117         addAttribute("label",label);
118         return this;
119     }
120
121     /**
122         Sets the VALUE="" attribute
123         @param value the VALUE="" attribute
124     */

125     public OptGroup setValue(String JavaDoc value)
126     {
127         addAttribute("value",value);
128         return this;
129     }
130
131     /**
132         Sets the disabled value
133         @param disabled true or false
134     */

135     public OptGroup setDisabled(boolean disabled)
136     {
137         if ( disabled == true )
138             addAttribute("disabled", NO_ATTRIBUTE_VALUE);
139         else
140             removeAttribute("disabled");
141             
142         return(this);
143     }
144     
145     /**
146         Adds an Element to the element.
147         @param hashcode name of element for hash table
148         @param element Adds an Element to the element.
149      */

150     public OptGroup addElement(String JavaDoc hashcode,Element element)
151     {
152         addElementToRegistry(hashcode,element);
153         return(this);
154     }
155
156     /**
157         Adds an Element to the element.
158         @param hashcode name of element for hash table
159         @param element Adds an Element to the element.
160      */

161     public OptGroup addElement(String JavaDoc hashcode,String JavaDoc element)
162     {
163         addElementToRegistry(hashcode,element);
164         return(this);
165     }
166
167     /**
168         Adds an Element to the element.
169         @param element Adds an Element to the element.
170      */

171     public OptGroup addElement(Element element)
172     {
173         addElementToRegistry(element);
174         return(this);
175     }
176     
177     /**
178         Adds an Element to the element.
179         @param element Adds an Element to the element.
180      */

181     public OptGroup addElement(String JavaDoc element)
182     {
183         addElementToRegistry(element);
184         return(this);
185     }
186     /**
187         Removes an Element from the element.
188         @param hashcode the name of the element to be removed.
189     */

190     public OptGroup removeElement(String JavaDoc hashcode)
191     {
192         removeElementFromRegistry(hashcode);
193         return(this);
194     }
195
196     /**
197         The onfocus event occurs when an element receives focus either by the
198         pointing device or by tabbing navigation. This attribute may be used
199         with the following elements: LABEL, INPUT, SELECT, TEXTAREA, and
200         BUTTON.
201         
202         @param The script
203     */

204     public void setOnFocus(String JavaDoc script)
205     {
206         addAttribute ( "onFocus", script );
207     }
208
209     /**
210         The onblur event occurs when an element loses focus either by the
211         pointing device or by tabbing navigation. It may be used with the same
212         elements as onfocus.
213         
214         @param The script
215     */

216     public void setOnBlur(String JavaDoc script)
217     {
218         addAttribute ( "onBlur", script );
219     }
220
221     /**
222         The onsubmit event occurs when a form is submitted. It only applies to
223         the FORM element.
224         
225         @param The script
226     */

227     public void setOnSubmit(String JavaDoc script)
228     {
229         addAttribute ( "onSubmit", script );
230     }
231
232     /**
233         The onreset event occurs when a form is reset. It only applies to the
234         FORM element.
235         
236         @param The script
237     */

238     public void setOnReset(String JavaDoc script)
239     {
240         addAttribute ( "onReset", script );
241     }
242
243     /**
244         The onselect event occurs when a user selects some text in a text
245         field. This attribute may be used with the INPUT and TEXTAREA elements.
246         
247         @param The script
248     */

249     public void setOnSelect(String JavaDoc script)
250     {
251         addAttribute ( "onSelect", script );
252     }
253
254     /**
255         The onchange event occurs when a control loses the input focus and its
256         value has been modified since gaining focus. This attribute applies to
257         the following elements: INPUT, SELECT, and TEXTAREA.
258         
259         @param The script
260     */

261     public void setOnChange(String JavaDoc script)
262     {
263         addAttribute ( "onChange", script );
264     }
265
266     /**
267         The onclick event occurs when the pointing device button is clicked
268         over an element. This attribute may be used with most elements.
269         
270         @param The script
271     */

272     public void setOnClick(String JavaDoc script)
273     {
274         addAttribute ( "onClick", script );
275     }
276     /**
277         The ondblclick event occurs when the pointing device button is double
278         clicked over an element. This attribute may be used with most elements.
279
280         @param The script
281     */

282     public void setOnDblClick(String JavaDoc script)
283     {
284         addAttribute ( "onDblClick", script );
285     }
286     /**
287         The onmousedown event occurs when the pointing device button is pressed
288         over an element. This attribute may be used with most elements.
289
290         @param The script
291     */

292     public void setOnMouseDown(String JavaDoc script)
293     {
294         addAttribute ( "onMouseDown", script );
295     }
296     /**
297         The onmouseup event occurs when the pointing device button is released
298         over an element. This attribute may be used with most elements.
299
300         @param The script
301     */

302     public void setOnMouseUp(String JavaDoc script)
303     {
304         addAttribute ( "onMouseUp", script );
305     }
306     /**
307         The onmouseover event occurs when the pointing device is moved onto an
308         element. This attribute may be used with most elements.
309
310         @param The script
311     */

312     public void setOnMouseOver(String JavaDoc script)
313     {
314         addAttribute ( "onMouseOver", script );
315     }
316     /**
317         The onmousemove event occurs when the pointing device is moved while it
318         is over an element. This attribute may be used with most elements.
319
320         @param The script
321     */

322     public void setOnMouseMove(String JavaDoc script)
323     {
324         addAttribute ( "onMouseMove", script );
325     }
326     /**
327         The onmouseout event occurs when the pointing device is moved away from
328         an element. This attribute may be used with most elements.
329
330         @param The script
331     */

332     public void setOnMouseOut(String JavaDoc script)
333     {
334         addAttribute ( "onMouseOut", script );
335     }
336
337     /**
338         The onkeypress event occurs when a key is pressed and released over an
339         element. This attribute may be used with most elements.
340         
341         @param The script
342     */

343     public void setOnKeyPress(String JavaDoc script)
344     {
345         addAttribute ( "onKeyPress", script );
346     }
347
348     /**
349         The onkeydown event occurs when a key is pressed down over an element.
350         This attribute may be used with most elements.
351         
352         @param The script
353     */

354     public void setOnKeyDown(String JavaDoc script)
355     {
356         addAttribute ( "onKeyDown", script );
357     }
358
359     /**
360         The onkeyup event occurs when a key is released over an element. This
361         attribute may be used with most elements.
362         
363         @param The script
364     */

365     public void setOnKeyUp(String JavaDoc script)
366     {
367         addAttribute ( "onKeyUp", script );
368     }
369 }
370
Popular Tags