KickJava   Java API By Example, From Geeks To Geeks.

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


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;TH&gt; object.
64     @version $Id: TH.java,v 1.6 2003/04/27 09:03:39 rdonkin Exp $
65     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
66     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
67 */

68 public class TH extends MultiPartElement implements Printable, MouseEvents, KeyEvents
69 {
70     /**
71         private initializer.
72     */

73     {
74         setElementType("th");
75     }
76
77     /**
78         Basic constructor. Use set* methods.
79     */

80     public TH()
81     {
82     }
83
84     /**
85         Basic Constructor use set* methods.
86     */

87     public TH(Element element)
88     {
89         addElement(element);
90     }
91
92     /**
93         Basic Constructor use set* methods.
94     */

95     public TH(String JavaDoc element)
96     {
97         addElement(element);
98     }
99
100     /**
101         Basic Constructor use set* methods.
102         @param close. Print the closing tag or not.
103     */

104     public TH(boolean close)
105     {
106         setNeedClosingTag(close);
107     }
108
109     /**
110         Sets the ABBR="" attribute.
111         @param cdata sets the ABBR="" attribute.
112     */

113     public TH setAbbr(String JavaDoc cdata)
114     {
115         addAttribute("abbr",cdata);
116         return(this);
117     }
118
119     /**
120         Sets the AXIS="" attribute
121         @param cdata sets the AXIS="" attribute
122     */

123     public TH setAxis(String JavaDoc cdata)
124     {
125         addAttribute("axis",cdata);
126         return(this);
127     }
128
129     /**
130         Sets the AXES="" attribute
131         @param id_refs list of id's for header cells
132     */

133     public TH setAxes(String JavaDoc id_refs)
134     {
135         addAttribute("axes",id_refs);
136         return(this);
137     }
138
139     /**
140         Sets the ROWSPAN="" attribute
141         @param span Number of rows spaned by cell
142     */

143     public TH setRowSpan(int span)
144     {
145         addAttribute("rowspan",Integer.toString(span));
146         return(this);
147     }
148
149     /**
150         Sets the ROWSPAN="" attribute
151         @param span Number of rows spaned by cell
152     */

153     public TH setRowSpan(String JavaDoc span)
154     {
155         addAttribute("rowspan",span);
156         return(this);
157     }
158
159     /**
160         Sets the COLSPAN="" attribute
161         @param span Number of columns spanned by cell
162     */

163     public TH setColSpan(int span)
164     {
165         addAttribute("colspan",Integer.toString(span));
166         return(this);
167     }
168
169     /**
170         Sets the COLSPAN="" attribute
171         @param span Number of columns spanned by cell
172     */

173     public TH setColSpan(String JavaDoc span)
174     {
175         addAttribute("colspan",span);
176         return(this);
177     }
178
179     /**
180         Sets word wrap on or off.
181         @param wrap turn word wrap on or off.
182     */

183     public TH setNoWrap(boolean wrap)
184     {
185         if ( wrap == true )
186             addAttribute("nowrap", NO_ATTRIBUTE_VALUE);
187         else
188             removeAttribute("nowrap");
189
190         return(this);
191     }
192
193     /**
194         Supplies user agents with a recommended cell width. (Pixel Values)
195         @param width how many pixels to make cell
196     */

197     public TH setWidth(int width)
198     {
199         addAttribute("width",Integer.toString(width));
200         return(this);
201     }
202     
203     /**
204         Supplies user agents with a recommended cell width. (Pixel Values)
205         @param width how many pixels to make cell
206     */

207     public TH setWidth(String JavaDoc width)
208     {
209         addAttribute("width",width);
210         return(this);
211     }
212
213     /**
214         Supplies user agents with a recommended cell height. (Pixel Values)
215         @param height how many pixels to make cell
216     */

217     public TH setHeight(int height)
218     {
219         addAttribute("height",Integer.toString(height));
220         return(this);
221     }
222
223     /**
224         Supplies user agents with a recommended cell height. (Pixel Values)
225         @param height how many pixels to make cell
226     */

227     public TH setHeight(String JavaDoc height)
228     {
229         addAttribute("height",height);
230         return(this);
231     }
232
233     /**
234         Sets the ALIGN="" attribute convience variables are provided in the AlignType interface
235         @param align Sets the ALIGN="" attribute
236     */

237     public TH setAlign(String JavaDoc align)
238     {
239         addAttribute("align",align);
240         return(this);
241     }
242
243     /**
244         Sets the VALIGN="" attribute convience variables are provided in the AlignType interface
245         @param valign Sets the ALIGN="" attribute
246     */

247     public TH setVAlign(String JavaDoc valign)
248     {
249         addAttribute("valign",valign);
250         return(this);
251     }
252
253     /**
254         Sets the CHAR="" attribute.
255         @param character the character to use for alignment.
256     */

257     public TH setChar(String JavaDoc character)
258     {
259         addAttribute("char",character);
260         return(this);
261     }
262
263     /**
264         Sets the CHAROFF="" attribute.
265         @param char_off When present this attribute specifies the offset
266         of the first occurrence of the alignment character on each line.
267     */

268     public TH setCharOff(int char_off)
269     {
270         addAttribute("charoff",Integer.toString(char_off));
271         return(this);
272     }
273
274     /**
275         Sets the CHAROFF="" attribute.
276         @param char_off When present this attribute specifies the offset
277         of the first occurrence of the alignment character on each line.
278     */

279     public TH setCharOff(String JavaDoc char_off)
280     {
281         addAttribute("charoff",char_off);
282         return(this);
283     }
284
285     /**
286         Sets the BGCOLOR="" attribute
287         @param color sets the background color of the cell.
288     */

289     public TH setBgColor(String JavaDoc color)
290     {
291         addAttribute("bgcolor",HtmlColor.convertColor(color));
292         return(this);
293     }
294
295     /**
296         Adds an Element to the element.
297         @param hashcode name of element for hash table
298         @param element Adds an Element to the element.
299      */

300     public TH addElement(String JavaDoc hashcode,Element element)
301     {
302         addElementToRegistry(hashcode,element);
303         return(this);
304     }
305
306     /**
307         Adds an Element to the element.
308         @param hashcode name of element for hash table
309         @param element Adds an Element to the element.
310      */

311     public TH addElement(String JavaDoc hashcode,String JavaDoc element)
312     {
313         addElementToRegistry(hashcode,element);
314         return(this);
315     }
316
317     /**
318         Adds an Element to the element.
319         @param element Adds an Element to the element.
320      */

321     public TH addElement(Element element)
322     {
323         addElementToRegistry(element);
324         return(this);
325     }
326
327     /**
328         Adds an Element to the element.
329         @param element Adds an Element to the element.
330      */

331     public TH addElement(String JavaDoc element)
332     {
333         addElementToRegistry(element);
334         return(this);
335     }
336     /**
337         Removes an Element from the element.
338         @param hashcode the name of the element to be removed.
339     */

340     public TH removeElement(String JavaDoc hashcode)
341     {
342         removeElementFromRegistry(hashcode);
343         return(this);
344     }
345
346     /**
347         The onclick event occurs when the pointing device button is clicked
348         over an element. This attribute may be used with most elements.
349         
350         @param The script
351     */

352     public void setOnClick(String JavaDoc script)
353     {
354         addAttribute ( "onClick", script );
355     }
356     /**
357         The ondblclick event occurs when the pointing device button is double
358         clicked over an element. This attribute may be used with most elements.
359
360         @param The script
361     */

362     public void setOnDblClick(String JavaDoc script)
363     {
364         addAttribute ( "onDblClick", script );
365     }
366     /**
367         The onmousedown event occurs when the pointing device button is pressed
368         over an element. This attribute may be used with most elements.
369
370         @param The script
371     */

372     public void setOnMouseDown(String JavaDoc script)
373     {
374         addAttribute ( "onMouseDown", script );
375     }
376     /**
377         The onmouseup event occurs when the pointing device button is released
378         over an element. This attribute may be used with most elements.
379
380         @param The script
381     */

382     public void setOnMouseUp(String JavaDoc script)
383     {
384         addAttribute ( "onMouseUp", script );
385     }
386     /**
387         The onmouseover event occurs when the pointing device is moved onto an
388         element. This attribute may be used with most elements.
389
390         @param The script
391     */

392     public void setOnMouseOver(String JavaDoc script)
393     {
394         addAttribute ( "onMouseOver", script );
395     }
396     /**
397         The onmousemove event occurs when the pointing device is moved while it
398         is over an element. This attribute may be used with most elements.
399
400         @param The script
401     */

402     public void setOnMouseMove(String JavaDoc script)
403     {
404         addAttribute ( "onMouseMove", script );
405     }
406     /**
407         The onmouseout event occurs when the pointing device is moved away from
408         an element. This attribute may be used with most elements.
409
410         @param The script
411     */

412     public void setOnMouseOut(String JavaDoc script)
413     {
414         addAttribute ( "onMouseOut", script );
415     }
416
417     /**
418         The onkeypress event occurs when a key is pressed and released over an
419         element. This attribute may be used with most elements.
420         
421         @param The script
422     */

423     public void setOnKeyPress(String JavaDoc script)
424     {
425         addAttribute ( "onKeyPress", script );
426     }
427
428     /**
429         The onkeydown event occurs when a key is pressed down over an element.
430         This attribute may be used with most elements.
431         
432         @param The script
433     */

434     public void setOnKeyDown(String JavaDoc script)
435     {
436         addAttribute ( "onKeyDown", script );
437     }
438
439     /**
440         The onkeyup event occurs when a key is released over an element. This
441         attribute may be used with most elements.
442         
443         @param The script
444     */

445     public void setOnKeyUp(String JavaDoc script)
446     {
447         addAttribute ( "onKeyUp", script );
448     }
449 }
450
Popular Tags