View Javadoc

1   package org.wcb.common;
2   
3   import javax.swing.table.AbstractTableModel;
4   
5   /***
6    * Created by IntelliJ IDEA.
7    * User: 00u2583
8    * Date: Dec 30, 2003
9    * Time: 1:43:10 PM
10   * To change this template use Options | File Templates.
11   */
12  public class ColorTableModel extends AbstractTableModel {
13  
14      final String[] columnNames = {"Description", "Color"};
15      private Object uiColors[][];
16  
17      public ColorTableModel(Object[][] colors)
18      {
19          this.uiColors = colors;
20      }
21  
22      public int getColumnCount() {
23          return columnNames.length;
24      }
25  
26      public int getRowCount() {
27          return uiColors.length;
28      }
29  
30      public String getColumnName(int col) {
31          return columnNames[col];
32      }
33  
34      public Object getValueAt(int row, int col) {
35          return uiColors[row][col];
36      }
37  
38      public void setValueAt(Object value, int row, int col) {
39          uiColors[row][col] = value;
40          fireTableCellUpdated(row, col);
41      }
42  
43      /***
44       * JTable uses this method to determine the default renderer/
45       * editor for each cell.
46       */
47      public Class getColumnClass(int c) {
48          return getValueAt(0, c).getClass();
49      }
50  
51      public boolean isCellEditable(int row, int col) {
52          if (col<1) return false;
53          else return true;
54      }
55  }
56