KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > mobilitools > util > gui > TableMap


1 /**
2  * In a chain of data manipulators some behaviour is common. TableM1
3  * provides most o1 this behavour and can be subclassed by filters
4  * that only need to override a handful of specific methods. TableMap
5  * implements TableModel by routing all requests to its model, and
6  * TableModelListener by routing all events to its listeners. Inserting
7  * a TableMap which has not been subclassed into a chain of table filters
8  * should have no effect.
9  *
10  * @version 1.4 12/17/97
11  * @author Philip Milne adapted by Bruno Dillenseger */

12
13 package org.objectweb.mobilitools.util.gui;
14
15 import javax.swing.table.*;
16 import javax.swing.event.TableModelListener JavaDoc;
17 import javax.swing.event.TableModelEvent JavaDoc;
18
19 public class TableMap extends AbstractTableModel
20                       implements TableModelListener JavaDoc {
21     protected TableModel model;
22
23     public TableModel getModel() {
24         return model;
25     }
26
27     public void setModel(TableModel model) {
28         this.model = model;
29         model.addTableModelListener(this);
30     }
31
32     // By default, implement TableModel by forwarding all messages
33
// to the model.
34

35     public Object JavaDoc getValueAt(int aRow, int aColumn) {
36         return model.getValueAt(aRow, aColumn);
37     }
38
39     public void setValueAt(Object JavaDoc aValue, int aRow, int aColumn) {
40         model.setValueAt(aValue, aRow, aColumn);
41     }
42
43     public int getRowCount() {
44         return (model == null) ? 0 : model.getRowCount();
45     }
46
47     public int getColumnCount() {
48         return (model == null) ? 0 : model.getColumnCount();
49     }
50
51     public String JavaDoc getColumnName(int aColumn) {
52         return model.getColumnName(aColumn);
53     }
54
55     public Class JavaDoc getColumnClass(int aColumn) {
56         return model.getColumnClass(aColumn);
57     }
58
59     public boolean isCellEditable(int row, int column) {
60          return model.isCellEditable(row, column);
61     }
62 //
63
// Implementation of the TableModelListener interface,
64
//
65
// By default forward all events to all the listeners.
66
public void tableChanged(TableModelEvent JavaDoc e) {
67         fireTableChanged(e);
68     }
69 }
70
Popular Tags