KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > datasource > test > CustomTableModel


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2005 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package com.jaspersoft.jasperserver.datasource.test;
29
30 import javax.swing.table.AbstractTableModel JavaDoc;
31
32
33 /**
34  * @author Teodor Danciu (teodord@users.sourceforge.net)
35  * @version $Id: CustomTableModel.java 3480 2006-05-28 11:36:00Z swood $
36  */

37 public class CustomTableModel extends AbstractTableModel JavaDoc
38 {
39
40
41     /**
42      *
43      */

44     private String JavaDoc[] columnNames = {"the_city", "id", "name", "street"};
45
46     /**
47      *
48      */

49     private Object JavaDoc[][] data =
50         {
51             {"Berne", new Integer JavaDoc(9), "James Schneider", "277 Seventh Av."},
52             {"Berne", new Integer JavaDoc(22), "Bill Ott", "250 - 20th Ave."},
53             {"Boston", new Integer JavaDoc(32), "Michael Ott", "339 College Av."},
54             {"Boston", new Integer JavaDoc(23), "Julia Heiniger", "358 College Av."},
55             {"Chicago", new Integer JavaDoc(39), "Mary Karsen", "202 College Av."},
56             {"Chicago", new Integer JavaDoc(35), "George Karsen", "412 College Av."},
57             {"Chicago", new Integer JavaDoc(11), "Julia White", "412 Upland Pl."},
58             {"Dallas", new Integer JavaDoc(47), "Janet Fuller", "445 Upland Pl."},
59             {"Dallas", new Integer JavaDoc(43), "Susanne Smith", "2 Upland Pl."},
60             {"Dallas", new Integer JavaDoc(40), "Susanne Miller", "440 - 20th Ave."},
61             {"Dallas", new Integer JavaDoc(36), "John Steel", "276 Upland Pl."},
62             {"Dallas", new Integer JavaDoc(37), "Michael Clancy", "19 Seventh Av."},
63             {"Dallas", new Integer JavaDoc(19), "Susanne Heiniger", "86 - 20th Ave."},
64             {"Dallas", new Integer JavaDoc(10), "Anne Fuller", "135 Upland Pl."},
65             {"Dallas", new Integer JavaDoc(4), "Sylvia Ringer", "365 College Av."},
66             {"Dallas", new Integer JavaDoc(0), "Laura Steel", "429 Seventh Av."},
67             {"Lyon", new Integer JavaDoc(38), "Andrew Heiniger", "347 College Av."},
68             {"Lyon", new Integer JavaDoc(28), "Susanne White", "74 - 20th Ave."},
69             {"Lyon", new Integer JavaDoc(17), "Laura Ott", "443 Seventh Av."},
70             {"Lyon", new Integer JavaDoc(2), "Anne Miller", "20 Upland Pl."},
71             {"New York", new Integer JavaDoc(46), "Andrew May", "172 Seventh Av."},
72             {"New York", new Integer JavaDoc(44), "Sylvia Ott", "361 College Av."},
73             {"New York", new Integer JavaDoc(41), "Bill King", "546 College Av."},
74             {"Oslo", new Integer JavaDoc(45), "Janet May", "396 Seventh Av."},
75             {"Oslo", new Integer JavaDoc(42), "Robert Ott", "503 Seventh Av."},
76             {"Paris", new Integer JavaDoc(25), "Sylvia Steel", "269 College Av."},
77             {"Paris", new Integer JavaDoc(18), "Sylvia Fuller", "158 - 20th Ave."},
78             {"Paris", new Integer JavaDoc(5), "Laura Miller", "294 Seventh Av."},
79             {"San Francisco", new Integer JavaDoc(48), "Robert White", "549 Seventh Av."},
80             {"San Francisco", new Integer JavaDoc(7), "James Peterson", "231 Upland Pl."}
81         };
82
83
84     /**
85      *
86      */

87     public CustomTableModel()
88     {
89     }
90
91
92     /**
93      *
94      */

95     public int getColumnCount()
96     {
97         return this.columnNames.length;
98     }
99
100
101     /**
102      *
103      */

104     public String JavaDoc getColumnName(int columnIndex)
105     {
106         return this.columnNames[columnIndex];
107     }
108
109
110     /**
111      *
112      */

113     public int getRowCount()
114     {
115         return this.data.length;
116     }
117
118
119     /**
120      *
121      */

122     public Object JavaDoc getValueAt(int rowIndex, int columnIndex)
123     {
124         return this.data[rowIndex][columnIndex];
125     }
126
127
128 }
129
Popular Tags