1 package net.sf.openrocket.gui.components;
3 import javax.swing.JTable;
4 import javax.swing.table.AbstractTableModel;
8 * TODO: LOW: This is currently unused.
10 public abstract class CollectionTable<T> extends JTable {
12 private final String[] columnNames;
13 private CollectionTableModel model;
16 protected CollectionTable(String[] columnNames) {
17 this.columnNames = columnNames.clone();
21 protected void initializeTable() {
22 model = new CollectionTableModel();
28 * Retrieve the object for the specified row number.
30 * @param row the row number being queried.
31 * @return the object at that row.
33 protected abstract T getModelObjectAt(int row);
35 protected abstract int getModelRowCount();
39 protected abstract Object getViewForModelObject(T object, int column);
41 protected Class<?> getViewColumnClass(int column) {
47 private class CollectionTableModel extends AbstractTableModel {
49 public int getColumnCount() {
50 return columnNames.length;
54 public String getColumnName(int column) {
55 return columnNames[column];
59 public Class<?> getColumnClass(int column) {
60 return getViewColumnClass(column);
65 public int getRowCount() {
66 return getModelRowCount();
70 public Object getValueAt(int row, int column) {
71 T value = getModelObjectAt(row);
72 return getViewForModelObject(value, column);