Java Reference
In-Depth Information
Example 16.2 Defining our AbstractTableModel
130 private Component
131 createList()
132 {
133 JScrollPane retval;
134
135 model = new AbstractTableModel()
136 {
137 private String [] columnNames = {"Account", "Owner", "Value"};
138
139 public String
140 getColumnName(int col) {
141 return columnNames[col];
142 } // getColumnName
143
144 public int
145 getRowCount()
146 {
147 int retval;
148
149 if (current != null) {
150 retval = current.size();
151 } else {
152 retval = 1; // testing only
153 }
154
155 return retval;
156
157 } // getRowCount
158
159 public int getColumnCount() { return columnNames.length; }
160
161 public Object
162 getValueAt(int row, int col) {
163 Object retval = null;
164 Account aa = null;
165 // return "---"; // rowData[row][col];
166 int count = 0;
167 for (Iterator itr=current.getAllSubs(); itr.hasNext(); )
168 {
169 count++;
170 aa = (Account) itr.next();
171 if (count > row) { break; }
172 } // next
Search WWH ::




Custom Search