KickJava   Java API By Example, From Geeks To Geeks.

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


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;TABLE&gt; object.
64     @version $Id: Table.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 Table extends MultiPartElement implements Printable, MouseEvents, KeyEvents
69 {
70     /**
71         Private iniitialization routine
72     */

73     {
74         setElementType("table");
75     }
76     public Table()
77     {
78     }
79
80     /**
81         Allows one to set the border size.
82         
83         @param border sets the BORDER="" attribute.
84     */

85     public Table(int border)
86     {
87         setBorder(border);
88     }
89
90     /**
91         Allows one to set the border size.
92         
93         @param border sets the BORDER="" attribute.
94     */

95     public Table(String JavaDoc border)
96     {
97         setBorder(border);
98     }
99
100     /**
101         Set the SUMMARY="" attribue.
102
103         @param summary sets the SUMMARY="" attribute.
104     */

105     public Table setSummary(String JavaDoc summary)
106     {
107         addAttribute("summary",summary);
108         return(this);
109     }
110
111     /**
112         Sets the ALIGN="" attribute.
113
114         @param align sets the ALIGN="" attribute. You can
115         use the AlignType.* variables for convience.
116     */

117     public Table setAlign(String JavaDoc align)
118     {
119         addAttribute("align",align);
120         return(this);
121     }
122
123     /**
124         Sets the WIDTH="" attribute.
125
126         @param width sets the WIDTH="" attribute.
127     */

128     public Table setWidth(String JavaDoc width)
129     {
130         addAttribute("width",width);
131         return(this);
132     }
133     /**
134         Sets the HEIGHT="" attribute.
135
136         @param width sets the HEIGHT="" attribute.
137     */

138     public Table setHeight(String JavaDoc height)
139     {
140         addAttribute("height",height);
141         return(this);
142     }
143     /**
144         Sets the WIDTH="" attribute.
145
146         @param width sets the WIDTH="" attribute.
147     */

148     public Table setWidth(int width)
149     {
150         addAttribute("width",Integer.toString(width));
151         return(this);
152     }
153     /**
154         Sets the HEIGHT="" attribute.
155
156         @param width sets the HEIGHT="" attribute.
157     */

158     public Table setHeight(int height)
159     {
160         addAttribute("height",Integer.toString(height));
161         return(this);
162     }
163     /**
164         Sets the COLS="" attribute.
165
166         @param width sets the COLS="" attribute.
167     */

168     public Table setCols(int cols)
169     {
170         addAttribute("cols",Integer.toString(cols));
171         return(this);
172     }
173     /**
174         Sets the COLS="" attribute.
175
176         @param width sets the COLS="" attribute.
177     */

178     public Table setCols(String JavaDoc cols)
179     {
180         addAttribute("cols",cols);
181         return(this);
182     }
183     /**
184         Sets the CELLPADING="" attribute.
185         @param cellpadding sets the CELLPADING="" attribute.
186     */

187     public Table setCellPadding(int cellpadding)
188     {
189         addAttribute("cellpadding",Integer.toString(cellpadding));
190         return(this);
191     }
192     /**
193         Sets the CELLSPACING="" attribute.
194         @param spacing sets the CELLSPACING="" attribute.
195     */

196     public Table setCellSpacing(int cellspacing)
197     {
198         addAttribute("cellspacing",Integer.toString(cellspacing));
199         return(this);
200     }
201     /**
202         Sets the CELLPADING="" attribute.
203         @param cellpadding sets the CELLPADING="" attribute.
204     */

205     public Table setCellPadding(String JavaDoc cellpadding)
206     {
207         addAttribute("cellpadding",cellpadding);
208         return(this);
209     }
210     /**
211         Sets the CELLSPACING="" attribute.
212         @param spacing sets the CELLSPACING="" attribute.
213     */

214     public Table setCellSpacing(String JavaDoc cellspacing)
215     {
216         addAttribute("cellspacing",cellspacing);
217         return(this);
218     }
219     /**
220         Sets the BORDER="" attribute.
221         @param border sets the BORDER="" attribute.
222     */

223     public Table setBorder(int border)
224     {
225         addAttribute("border",Integer.toString(border));
226         return(this);
227     }
228     /**
229         Sets the BORDER="" attribute.
230         @param border sets the BORDER="" attribute.
231     */

232     public Table setBorder(String JavaDoc border)
233     {
234         addAttribute("border",border);
235         return(this);
236     }
237     /**
238         Sets the FRAME="" attribute.
239         @param frame sets the FRAME="" attribute.
240     */

241     public Table setFrame(String JavaDoc frame)
242     {
243         addAttribute("frame",frame);
244         return(this);
245     }
246     /**
247         Sets the RULES="" attribute.
248         @param rules sets the RULES="" attribute.
249     */

250     public Table setRules(String JavaDoc rules)
251     {
252         addAttribute("rules",rules);
253         return(this);
254     }
255
256     /**
257         Sets the BGCOLOR="" attribute
258         @param color the BGCOLOR="" attribute
259     */

260     public Table setBgColor(String JavaDoc color)
261     {
262         addAttribute("bgcolor",HtmlColor.convertColor(color));
263         return this;
264     }
265
266     /**
267         Adds an Element to the element.
268         @param hashcode name of element for hash table
269         @param element Adds an Element to the element.
270      */

271     public Table addElement(String JavaDoc hashcode,Element element)
272     {
273         addElementToRegistry(hashcode,element);
274         return(this);
275     }
276
277     /**
278         Adds an Element to the element.
279         @param hashcode name of element for hash table
280         @param element Adds an Element to the element.
281      */

282     public Table addElement(String JavaDoc hashcode,String JavaDoc element)
283     {
284         addElementToRegistry(hashcode,element);
285         return(this);
286     }
287
288     /**
289         Adds an Element to the element.
290         @param element Adds an Element to the element.
291      */

292     public Table addElement(Element element)
293     {
294         addElementToRegistry(element);
295         return(this);
296     }
297
298     /**
299         Adds an Element to the element.
300         @param element Adds an Element to the element.
301      */

302     public Table addElement(String JavaDoc element)
303     {
304         addElementToRegistry(element);
305         return(this);
306     }
307     /**
308         Removes an Element from the element.
309         @param hashcode the name of the element to be removed.
310     */

311     public Table removeElement(String JavaDoc hashcode)
312     {
313         removeElementFromRegistry(hashcode);
314         return(this);
315     }
316
317     /**
318         The onclick event occurs when the pointing device button is clicked
319         over an element. This attribute may be used with most elements.
320         
321         @param The script
322     */

323     public void setOnClick(String JavaDoc script)
324     {
325         addAttribute ( "onClick", script );
326     }
327     /**
328         The ondblclick event occurs when the pointing device button is double
329         clicked over an element. This attribute may be used with most elements.
330
331         @param The script
332     */

333     public void setOnDblClick(String JavaDoc script)
334     {
335         addAttribute ( "onDblClick", script );
336     }
337     /**
338         The onmousedown event occurs when the pointing device button is pressed
339         over an element. This attribute may be used with most elements.
340
341         @param The script
342     */

343     public void setOnMouseDown(String JavaDoc script)
344     {
345         addAttribute ( "onMouseDown", script );
346     }
347     /**
348         The onmouseup event occurs when the pointing device button is released
349         over an element. This attribute may be used with most elements.
350
351         @param The script
352     */

353     public void setOnMouseUp(String JavaDoc script)
354     {
355         addAttribute ( "onMouseUp", script );
356     }
357     /**
358         The onmouseover event occurs when the pointing device is moved onto an
359         element. This attribute may be used with most elements.
360
361         @param The script
362     */

363     public void setOnMouseOver(String JavaDoc script)
364     {
365         addAttribute ( "onMouseOver", script );
366     }
367     /**
368         The onmousemove event occurs when the pointing device is moved while it
369         is over an element. This attribute may be used with most elements.
370
371         @param The script
372     */

373     public void setOnMouseMove(String JavaDoc script)
374     {
375         addAttribute ( "onMouseMove", script );
376     }
377     /**
378         The onmouseout event occurs when the pointing device is moved away from
379         an element. This attribute may be used with most elements.
380
381         @param The script
382     */

383     public void setOnMouseOut(String JavaDoc script)
384     {
385         addAttribute ( "onMouseOut", script );
386     }
387
388     /**
389         The onkeypress event occurs when a key is pressed and released over an
390         element. This attribute may be used with most elements.
391         
392         @param The script
393     */

394     public void setOnKeyPress(String JavaDoc script)
395     {
396         addAttribute ( "onKeyPress", script );
397     }
398
399     /**
400         The onkeydown event occurs when a key is pressed down over an element.
401         This attribute may be used with most elements.
402         
403         @param The script
404     */

405     public void setOnKeyDown(String JavaDoc script)
406     {
407         addAttribute ( "onKeyDown", script );
408     }
409
410     /**
411         The onkeyup event occurs when a key is released over an element. This
412         attribute may be used with most elements.
413         
414         @param The script
415     */

416     public void setOnKeyUp(String JavaDoc script)
417     {
418         addAttribute ( "onKeyUp", script );
419     }
420 }
421
Popular Tags