KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > util > display > HtmlTable


1 /**
2 * Copyright (c) 2004-2005 jManage.org
3 *
4 * This is a free software; you can redistribute it and/or
5 * modify it under the terms of the license at
6 * http://www.jmanage.org.
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */

14 package org.jmanage.util.display;
15
16 import java.util.Iterator JavaDoc;
17
18 /**
19  *
20  * <p>
21  * Date: Sep 29, 2005
22  * @author Rakesh Kalra
23  */

24 public class HtmlTable extends AbstractTable {
25
26     public String JavaDoc draw(){
27         StringBuffer JavaDoc buff = new StringBuffer JavaDoc();
28         buff.append("<table class=\"HtmlTable\">");
29         drawHeader(buff);
30         for(Iterator JavaDoc it=getRows().iterator(); it.hasNext(); ){
31             drawRow(buff, (String JavaDoc[])it.next());
32         }
33         buff.append("</table>");
34         return buff.toString();
35     }
36
37     private void drawHeader(StringBuffer JavaDoc buff){
38         buff.append("<tr>");
39         String JavaDoc[] header = getHeader();
40         for(int i=0; i<header.length; i++){
41             buff.append("<td valign=\"top\" style=\"border: none;font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px\">");
42             buff.append("<b>");
43             buff.append(header[i]);
44             buff.append("</b></td>");
45         }
46         buff.append("</tr>");
47     }
48
49     private void drawRow(StringBuffer JavaDoc buff, String JavaDoc[] row){
50         buff.append("<tr>");
51         for(int i=0; i<row.length; i++){
52             buff.append("<td valign=\"top\" style=\"border: none;font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px\">");
53             buff.append(row[i]);
54             buff.append("</td>");
55         }
56         buff.append("</tr>");
57     }
58 }
59
Popular Tags