KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > monitor > client > DisplayTableModel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.monitor.client;
21
22 import java.util.*;
23 import javax.swing.table.TableModel JavaDoc;
24 import javax.swing.table.AbstractTableModel JavaDoc;
25 import org.openide.util.NbBundle;
26
27 /**
28  * DisplayTableModel.java
29  *
30  *
31  * Created: Fri Jan 25 13:37:39 2002
32  *
33  * @author Ana von Klopp
34  * @version
35  */

36 public class DisplayTableModel extends AbstractTableModel JavaDoc {
37
38     private Object JavaDoc[][] data = null;
39     private boolean editable, editableNames;
40     private int numCols = 3;
41
42     private static final boolean debug = false;
43
44     public DisplayTableModel(Object JavaDoc[][] data,
45             boolean editable,
46             boolean editableNames) {
47     this.data = data;
48     this.editable = editable;
49     this.editableNames = editableNames;
50     }
51     
52     public String JavaDoc getColumnName(int col) {
53     return ""; // NOI18N
54
//return headers[col].toString();
55
}
56     
57     public int getRowCount() { return data.length; }
58     public int getColumnCount() { return numCols; }
59     public Object JavaDoc getValueAt(int row, int col) {
60     return data[row][col];
61     }
62     public boolean isCellEditable(int row, int col) {
63     if(editable) {
64         if(col == 0) return editableNames;
65         if(col == 1) return true;
66         if(col == 2) return true;
67     }
68     if(col == 2) return true;
69     return false;
70     }
71     
72     public void setValueAt(Object JavaDoc value, int row, int col) {
73     data[row][col] = value;
74     fireTableCellUpdated(row, col);
75     }
76
77     void log(String JavaDoc s) {
78     System.out.println("DisplayTableModel::" + s); // NOI18N
79
}
80     
81 } // DisplayTableModel
82

83
Popular Tags