Index: javax/swing/JTable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.20
diff -u -r1.20 JTable.java
--- javax/swing/JTable.java 31 Dec 2004 10:19:44 -0000 1.20
+++ javax/swing/JTable.java 7 Jan 2005 18:31:43 -0000
@@ -42,6 +42,7 @@
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
+import java.awt.Point;
import java.util.Hashtable;
import java.util.Vector;
@@ -571,6 +572,58 @@
repaint();
}
+ /**
+ * Returns index of the column that contains specified point
+ * or -1 if this table doesn't contain this point.
+ *
+ * @param point point to identify the column
+ * @return index of the column that contains specified point or
+ * -1 if this table doesn't contain this point.
+ */
+ public int columnAtPoint(Point point)
+ {
+ int x0 = getLocation().x;
+ int ncols = getColumnCount();
+ Dimension gap = getIntercellSpacing();
+ TableColumnModel cols = getColumnModel();
+ int x = point.x;
+
+ for (int i = 0; i < ncols; ++i)
+ {
+ int width = cols.getColumn(i).getWidth() + (gap == null ? 0 : gap.width);
+ if (0 <= x && x < width)
+ return i;
+ x -= width;
+ }
+
+ return -1;
+ }
+
+ /**
+ * Returns index of the row that contains specified point or
+ * -1 if this table doesn't contain this point.
+ *
+ * @param point point to identify the row
+ * @return index of the row that contains specified point or
+ * -1 if this table doesn't contain this point.
+ */
+ public int rowAtPoint(Point point)
+ {
+ int y0 = getLocation().y;
+ int nrows = getRowCount();
+ Dimension gap = getIntercellSpacing();
+ int height = getRowHeight() + (gap == null ? 0 : gap.height);
+ int y = point.y;
+
+ for (int i = 0; i < nrows; ++i)
+ {
+ if (0 <= y && y < height)
+ return i;
+ y -= height;
+ }
+
+ return -1;
+ }
/**
* Calculate the visible rectangle for a particular row and column. The
@@ -921,11 +974,11 @@
break;
case ListSelectionModel.SINGLE_INTERVAL_SELECTION:
- sum = hi - lo;
+ sum = hi - lo + 1;
break;
case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION:
- for (int i = lo; i < hi; ++i)
+ for (int i = lo; i <= hi; ++i)
if (lsm.isSelectedIndex(i))
++sum;
break;
@@ -952,12 +1005,12 @@
break;
case ListSelectionModel.SINGLE_INTERVAL_SELECTION:
- for (int i = lo; i < hi; ++i)
+ for (int i = lo; i <= hi; ++i)
ret[j++] = i;
break;
case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION:
- for (int i = lo; i < hi; ++i)
+ for (int i = lo; i <= hi; ++i)
if (lsm.isSelectedIndex(i))
ret[j++] = i;
break;
@@ -1328,13 +1381,16 @@
/**
* Set the value of the address@hidden #selectionMode} property by
- * delegation to the address@hidden #selectionModel} field.
+ * delegation to the address@hidden #selectionModel} field. The same selection
+ * mode is set for row and column selection models.
*
* @param s The new value of the property
*/
public void setSelectionMode(int s)
- {
- selectionModel.setSelectionMode(s);
+ {
+ selectionModel.setSelectionMode(s);
+ columnModel.getSelectionModel().setSelectionMode(s);
+
repaint();
}
Index: javax/swing/plaf/basic/BasicTableUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTableUI.java,v
retrieving revision 1.4
diff -u -r1.4 BasicTableUI.java
--- javax/swing/plaf/basic/BasicTableUI.java 16 Dec 2004 19:10:04 -0000 1.4
+++ javax/swing/plaf/basic/BasicTableUI.java 7 Jan 2005 18:31:43 -0000
@@ -104,45 +104,12 @@
{
Point begin, curr;
- private int getRowForPoint(Point p)
- {
- int y0 = table.getLocation().y;
- int nrows = table.getRowCount();
- Dimension gap = table.getIntercellSpacing();
- int height = table.getRowHeight() + (gap == null ? 0 : gap.height);
- int y = p.y;
- for (int i = 0; i < nrows; ++i)
- {
- if (0 <= y && y < height)
- return i;
- y -= height;
- }
- return -1;
- }
-
- private int getColForPoint(Point p)
- {
- int x0 = table.getLocation().x;
- int ncols = table.getColumnCount();
- Dimension gap = table.getIntercellSpacing();
- TableColumnModel cols = table.getColumnModel();
- int x = p.x;
- for (int i = 0; i < ncols; ++i)
- {
- int width = cols.getColumn(i).getWidth() + (gap == null ? 0 : gap.width);
- if (0 <= x && x < width)
- return i;
- x -= width;
- }
- return -1;
- }
-
private void updateSelection()
{
if (table.getRowSelectionAllowed())
{
- int lo_row = getRowForPoint(begin);
- int hi_row = getRowForPoint(curr);
+ int lo_row = table.rowAtPoint(begin);
+ int hi_row = table.rowAtPoint(curr);
ListSelectionModel rowModel = table.getSelectionModel();
if (lo_row != -1 && hi_row != -1)
rowModel.setSelectionInterval(lo_row, hi_row);
@@ -150,8 +117,8 @@
if (table.getColumnSelectionAllowed())
{
- int lo_col = getColForPoint(begin);
- int hi_col = getColForPoint(curr);
+ int lo_col = table.columnAtPoint(begin);
+ int hi_col = table.columnAtPoint(curr);
ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
if (lo_col != -1 && hi_col != -1)
colModel.setSelectionInterval(lo_col, hi_col);
Index: javax/swing/table/DefaultTableColumnModel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/table/DefaultTableColumnModel.java,v
retrieving revision 1.11
diff -u -r1.11 DefaultTableColumnModel.java
--- javax/swing/table/DefaultTableColumnModel.java 30 Dec 2004 19:07:20 -0000 1.11
+++ javax/swing/table/DefaultTableColumnModel.java 7 Jan 2005 18:31:43 -0000
@@ -298,7 +298,40 @@
*/
public int[] getSelectedColumns()
{
- return null; // TODO
+ // FIXME: Implementation of this method was taken from private method
+ // JTable.getSelections(), which is used in various places in JTable
+ // including selected row calculations and cannot be simply removed.
+ // This design should be improved to illuminate duplication of code.
+
+ ListSelectionModel lsm = this.selectionModel;
+ int sz = getSelectedColumnCount();
+ int [] ret = new int[sz];
+
+ int lo = lsm.getMinSelectionIndex();
+ int hi = lsm.getMaxSelectionIndex();
+ int j = 0;
+ java.util.ArrayList ls = new java.util.ArrayList();
+ if (lo != -1 && hi != -1)
+ {
+ switch (lsm.getSelectionMode())
+ {
+ case ListSelectionModel.SINGLE_SELECTION:
+ ret[0] = lo;
+ break;
+
+ case ListSelectionModel.SINGLE_INTERVAL_SELECTION:
+ for (int i = lo; i <= hi; ++i)
+ ret[j++] = i;
+ break;
+
+ case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION:
+ for (int i = lo; i <= hi; ++i)
+ if (lsm.isSelectedIndex(i))
+ ret[j++] = i;
+ break;
+ }
+ }
+ return ret;
}
/**
@@ -307,7 +340,37 @@
*/
public int getSelectedColumnCount()
{
- return 0; // TODO
+ // FIXME: Implementation of this method was taken from private method
+ // JTable.countSelections(), which is used in various places in JTable
+ // including selected row calculations and cannot be simply removed.
+ // This design should be improved to illuminate duplication of code.
+
+ ListSelectionModel lsm = this.selectionModel;
+ int lo = lsm.getMinSelectionIndex();
+ int hi = lsm.getMaxSelectionIndex();
+ int sum = 0;
+
+ if (lo != -1 && hi != -1)
+ {
+ switch (lsm.getSelectionMode())
+ {
+ case ListSelectionModel.SINGLE_SELECTION:
+ sum = 1;
+ break;
+
+ case ListSelectionModel.SINGLE_INTERVAL_SELECTION:
+ sum = hi - lo + 1;
+ break;
+
+ case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION:
+ for (int i = lo; i <= hi; ++i)
+ if (lsm.isSelectedIndex(i))
+ ++sum;
+ break;
+ }
+ }
+
+ return sum;
}
/**
Index: javax/swing/table/DefaultTableModel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/table/DefaultTableModel.java,v
retrieving revision 1.8
diff -u -r1.8 DefaultTableModel.java
--- javax/swing/table/DefaultTableModel.java 22 Oct 2004 12:44:01 -0000 1.8
+++ javax/swing/table/DefaultTableModel.java 7 Jan 2005 18:31:43 -0000
@@ -1,5 +1,5 @@
/* DefaultTableModel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,15 +44,19 @@
import javax.swing.event.TableModelEvent;
/**
- * DefaultTableModel
+ * A two dimensional data structure used to store Object
+ * instances, usually for display in a JTable
component.
+ *
* @author Andrew Selkirk
*/
public class DefaultTableModel extends AbstractTableModel
implements Serializable
{
static final long serialVersionUID = 6680042567037222321L;
+
/**
- * dataVector
+ * Storage for the rows in the table (each row is itself
+ * a Vector
).
*/
protected Vector dataVector;
@@ -62,7 +66,7 @@
protected Vector columnIdentifiers;
/**
- * Constructor DefaultTableModel
+ * Creates an empty table with zero rows and zero columns.
*/
public DefaultTableModel()
{
@@ -70,9 +74,11 @@
}
/**
- * Constructor DefaultTableModel
- * @param value0 TODO
- * @param value1 TODO
+ * Creates a new table with the specified number of rows and columns.
+ * All cells in the table are initially empty (set to null
).
+ *
+ * @param numRows the number of rows.
+ * @param numColumns the number of columns.
*/
public DefaultTableModel(int numRows, int numColumns)
{
@@ -81,20 +87,28 @@
for (int i = 0; i < numColumns; i++)
{
defaultNames.add(super.getColumnName(i));
+ }
+ for (int r = 0; r < numRows; r++)
+ {
Vector tmp = new Vector(numColumns);
tmp.setSize(numColumns);
data.add(tmp);
- }
- setDataVector(defaultNames, data);
+ }
+ setDataVector(data, defaultNames);
}
/**
- * Constructor DefaultTableModel
- * @param value0 TODO
- * @param value1 TODO
+ * Creates a new table with the specified column names and number of
+ * rows. The number of columns is determined by the number of column
+ * names supplied.
+ *
+ * @param columnNames the column names.
+ * @param numRows the number of rows.
*/
public DefaultTableModel(Vector columnNames, int numRows)
{
+ if (numRows < 0)
+ throw new IllegalArgumentException("numRows < 0");
Vector data = new Vector();
int numColumns = 0;
@@ -111,9 +125,10 @@
}
/**
- * Constructor DefaultTableModel
- * @param value0 TODO
- * @param value1 TODO
+ * Creates a new table with the specified column names and row count.
+ *
+ * @param columnNames the column names.
+ * @param numRows the number of rows.
*/
public DefaultTableModel(Object[] columnNames, int numRows)
{
@@ -121,9 +136,10 @@
}
/**
- * Constructor DefaultTableModel
- * @param value0 TODO
- * @param value1 TODO
+ * Creates a new table with the specified data values and column names.
+ *
+ * @param data the data values.
+ * @param columnNames the column names.
*/
public DefaultTableModel(Vector data, Vector columnNames)
{
@@ -131,9 +147,10 @@
}
/**
- * Constructor DefaultTableModel
- * @param value0 TODO
- * @param value1 TODO
+ * Creates a new table with the specified data values and column names.
+ *
+ * @param data the data values.
+ * @param columnNames the column names.
*/
public DefaultTableModel(Object[][] data, Object[] columnNames)
{
@@ -141,8 +158,9 @@
}
/**
- * getDataVector
- * @returns Vector
+ * Returns the vector containing the row data for the table.
+ *
+ * @returns The data vector.
*/
public Vector getDataVector()
{
@@ -150,9 +168,16 @@
}
/**
- * setDataVector
- * @param value0 TODO
- * @param value1 TODO
+ * Sets the data and column identifiers for the table. The data vector
+ * contains a Vector
for each row in the table - if the
+ * number of objects in each row does not match the number of column
+ * names specified, the row data is truncated or expanded (by adding
+ * null
values) as required.
+ *
+ * @param data the data for the table (a vector of row vectors).
+ * @param columnNames the column names.
+ *
+ * @throws NullPointerException if either argument is null
.
*/
public void setDataVector(Vector data, Vector columnNames)
{
@@ -164,9 +189,12 @@
}
/**
- * setDataVector
- * @param value0 TODO
- * @param value1 TODO
+ * Sets the data and column identifiers for the table.
+ *
+ * @param data the data for the table.
+ * @param columnNames the column names.
+ *
+ * @throws NullPointerException if either argument is null
.
*/
public void setDataVector(Object[][] data, Object[] columnNames)
{
@@ -175,8 +203,11 @@
}
/**
- * newDataAvailable
- * @param value0 TODO
+ * Sends the specified event
to all registered listeners.
+ * This method is equivalent to
+ * address@hidden AbstractTableModel#fireTableChanged(TableModelEvent)}.
+ *
+ * @param event the event.
*/
public void newDataAvailable(TableModelEvent event)
{
@@ -184,8 +215,11 @@
}
/**
- * newRowsAdded
- * @param value0 TODO
+ * Sends the specified event
to all registered listeners.
+ * This method is equivalent to
+ * address@hidden AbstractTableModel#fireTableChanged(TableModelEvent)}.
+ *
+ * @param event the event.
*/
public void newRowsAdded(TableModelEvent event)
{
@@ -193,8 +227,11 @@
}
/**
- * rowsRemoved
- * @param value0 TODO
+ * Sends the specified event
to all registered listeners.
+ * This method is equivalent to
+ * address@hidden AbstractTableModel#fireTableChanged(TableModelEvent)}.
+ *
+ * @param event the event.
*/
public void rowsRemoved(TableModelEvent event)
{
@@ -202,18 +239,26 @@
}
/**
- * setColumnIdentifiers
- * @param value0 TODO
+ * Sets the column identifiers, updates the data rows (truncating
+ * or padding each row with null
values) to match the
+ * number of columns, and sends a address@hidden TableModelEvent} to all
+ * registered listeners.
+ *
+ * @param columnIdentifiers the column identifiers.
*/
public void setColumnIdentifiers(Vector columnIdentifiers)
{
this.columnIdentifiers = columnIdentifiers;
- setColumnCount(columnIdentifiers.size());
+ setColumnCount((columnIdentifiers == null ? 0 : columnIdentifiers.size()));
}
/**
- * setColumnIdentifiers
- * @param value0 TODO
+ * Sets the column identifiers, updates the data rows (truncating
+ * or padding each row with null
values) to match the
+ * number of columns, and sends a address@hidden TableModelEvent} to all
+ * registered listeners.
+ *
+ * @param columnIdentifiers the column identifiers.
*/
public void setColumnIdentifiers(Object[] columnIdentifiers)
{
@@ -221,8 +266,9 @@
}
/**
- * setNumRows
- * @param value0 TODO
+ * This method is obsolete, use address@hidden #setRowCount(int)} instead.
+ *
+ * @param numRows the number of rows.
*/
public void setNumRows(int numRows)
{
@@ -230,18 +276,40 @@
}
/**
- * setRowCount
- * @param value0 TODO
+ * Sets the number of rows in the table. If rowCount
is less
+ * than the current number of rows in the table, rows are discarded.
+ * If rowCount
is greater than the current number of rows in
+ * the table, new (empty) rows are added.
+ *
+ * @param the row count.
*/
public void setRowCount(int rowCount)
{
- dataVector.setSize(rowCount);
- fireTableDataChanged();
+ int existingRowCount = dataVector.size();
+ if (rowCount < existingRowCount)
+ {
+ dataVector.setSize(rowCount);
+ fireTableRowsDeleted(rowCount,existingRowCount-1);
+ }
+ else
+ {
+ int rowsToAdd = rowCount - existingRowCount;
+ for (int i = 0; i < rowsToAdd; i++)
+ {
+ Vector tmp = new Vector();
+ tmp.setSize(columnIdentifiers.size());
+ dataVector.add(tmp);
+ }
+ fireTableRowsInserted(existingRowCount,rowCount-1);
+ }
}
/**
- * setColumnCount
- * @param value0 TODO
+ * Sets the number of columns in the table. Existing rows are truncated
+ * or padded with null
values to match the new column count.
+ * A address@hidden TableModelEvent} is sent to all registered listeners.
+ *
+ * @param columnCount the column count.
*/
public void setColumnCount(int columnCount)
{
@@ -249,13 +317,16 @@
{
((Vector) dataVector.get(i)).setSize(columnCount);
}
- columnIdentifiers.setSize(columnCount);
+ if (columnIdentifiers != null)
+ columnIdentifiers.setSize(columnCount);
fireTableDataChanged();
}
/**
- * addColumn
- * @param value0 TODO
+ * Adds a column with the specified name to the table. All cell values
+ * for the column are initially set to null
.
+ *
+ * @param columnName the column name (null
permitted).
*/
public void addColumn(Object columnName)
{
@@ -263,21 +334,52 @@
}
/**
- * addColumn
- * @param value0 TODO
- * @param value1 TODO
+ * Adds a column with the specified name and data values to the table.
+ *
+ * @param columnName the column name (null
permitted).
+ * @param columnData the column data.
*/
public void addColumn(Object columnName, Vector columnData)
{
- addColumn(columnName, columnData == null ? null : columnData.toArray());
+ Object[] dataArray = null;
+ if (columnData != null)
+ {
+ int rowCount = dataVector.size();
+ if (columnData.size() < rowCount)
+ columnData.setSize(rowCount);
+ dataArray = columnData.toArray();
+ }
+ addColumn(columnName, dataArray);
}
/**
- * addColumn
- * @param value0 TODO
- * @param value1 TODO
+ * Adds a column with the specified name and data values to the table.
+ *
+ * @param columnName the column name (null
permitted).
+ * @param columnData the column data.
*/
public void addColumn(Object columnName, Object[] columnData) {
+ if (columnData != null)
+ {
+ // check columnData array for cases where the number of items
+ // doesn't match the number of rows in the existing table
+ if (columnData.length > dataVector.size())
+ {
+ int rowsToAdd = columnData.length - dataVector.size();
+ for (int i = 0; i < rowsToAdd; i++)
+ {
+ Vector tmp = new Vector();
+ tmp.setSize(columnIdentifiers.size());
+ dataVector.add(tmp);
+ }
+ }
+ else if (columnData.length < dataVector.size())
+ {
+ Object[] tmp = new Object[dataVector.size()];
+ System.arraycopy(columnData, 0, tmp, 0, columnData.length);
+ columnData = tmp;
+ }
+ }
for (int i = 0; i < dataVector.size(); ++i)
{
((Vector) dataVector.get(i)).add(columnData == null ? null : columnData[i]);
@@ -287,62 +389,79 @@
}
/**
- * addRow
- * @param value0 TODO
+ * Adds a new row containing the specified data to the table and sends a
+ * address@hidden TableModelEvent} to all registered listeners.
+ *
+ * @param rowData the row data (null
permitted).
*/
public void addRow(Vector rowData) {
dataVector.add(rowData);
- fireTableDataChanged();
+ newRowsAdded(new TableModelEvent(
+ this, dataVector.size(), dataVector.size(), -1, TableModelEvent.INSERT)
+ );
}
/**
- * addRow
- * @param value0 TODO
+ * Adds a new row containing the specified data to the table and sends a
+ * address@hidden TableModelEvent} to all registered listeners.
+ *
+ * @param rowData the row data (null
permitted).
*/
public void addRow(Object[] rowData) {
addRow(convertToVector(rowData));
}
/**
- * insertRow
- * @param value0 TODO
- * @param value1 TODO
+ * Inserts a new row into the table.
+ *
+ * @param row the row index.
+ * @param rowData the row data.
*/
public void insertRow(int row, Vector rowData) {
dataVector.add(row, rowData);
- fireTableDataChanged();
+ fireTableRowsInserted(row,row);
}
/**
- * insertRow
- * @param value0 TODO
- * @param value1 TODO
+ * Inserts a new row into the table.
+ *
+ * @param row the row index.
+ * @param rowData the row data.
*/
public void insertRow(int row, Object[] rowData) {
insertRow(row, convertToVector(rowData));
}
/**
- * moveRow
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
+ * Moves the rows from startIndex
to endIndex
+ * (inclusive) to the specified row.
+ *
+ * @param startIndex the start row.
+ * @param endIndex the end row.
+ * @param toIndex the row to move to.
*/
public void moveRow(int startIndex, int endIndex, int toIndex) {
- for (int index = 0; index < (endIndex - startIndex); index++) {
- Vector vector = (Vector) dataVector.remove(startIndex);
- dataVector.add(toIndex, vector);
+ Vector removed = new Vector();
+ for (int i = endIndex; i >= startIndex; i--)
+ {
+ removed.add(this.dataVector.remove(i));
+ }
+ for (int i = 0; i <= endIndex - startIndex; i++)
+ {
+ dataVector.insertElementAt(removed.get(i), toIndex);
}
fireTableDataChanged();
}
/**
- * removeRow
- * @param value0 TODO
+ * Removes a row from the table and sends a address@hidden TableModelEvent} to
+ * all registered listeners.
+ *
+ * @param row the row index.
*/
public void removeRow(int row) {
dataVector.remove(row);
- fireTableDataChanged();
+ fireTableRowsDeleted(row,row);
}
/**
@@ -354,63 +473,86 @@
}
/**
- * getColumnCount
- * @returns int
+ * Returns the number of columns in the model.
+ *
+ * @return The column count.
*/
public int getColumnCount() {
- return columnIdentifiers.size();
+ return (columnIdentifiers == null ? 0 : columnIdentifiers.size());
}
/**
- * getColumnName
- * @param value0 TODO
- * @returns String
+ * Returns the name of the specified column.
+ *
+ * @param column the column index.
+ *
+ * @returns The column name.
*/
public String getColumnName(int column) {
- // Check for Column
- if (columnIdentifiers == null || column >= getColumnCount()) {
- return super.getColumnName(column);
+ String result = "";
+ if (columnIdentifiers == null)
+ result = super.getColumnName(column);
+ else
+ {
+ if (column < getColumnCount())
+ {
+ Object id = columnIdentifiers.get(column);
+ if (id != null)
+ result = id.toString();
+ else
+ result = super.getColumnName(column);
+ }
}
-
- // Return Column name
- return (String) columnIdentifiers.get(column);
+ return result;
}
/**
- * isCellEditable
- * @param value0 TODO
- * @param value1 TODO
- * @returns boolean
+ * Returns true
if the specified cell can be modified, and
+ * false
otherwise. For this implementation, the method
+ * always returns true
.
+ *
+ * @param row the row index.
+ * @param column the column index.
+ *
+ * @returns true
in all cases.
*/
public boolean isCellEditable(int row, int column) {
return true;
}
/**
- * getValueAt
- * @param value0 TODO
- * @param value1 TODO
- * @returns Object
+ * Returns the value at the specified cell in the table.
+ *
+ * @param row the row index.
+ * @param column the column index.
+ *
+ * @returns The value (Object
, possibly null
) at
+ * the specified cell in the table.
*/
public Object getValueAt(int row, int column) {
return ((Vector) dataVector.get(row)).get(column);
}
/**
- * setValueAt
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
+ * Sets the value for the specified cell in the table and sends a
+ * address@hidden TableModelEvent} to all registered listeners.
+ *
+ * @param value the value (Object
, null
permitted).
+ * @param row the row index.
+ * @param column the column index.
*/
public void setValueAt(Object value, int row, int column) {
((Vector) dataVector.get(row)).set(column, value);
- fireTableDataChanged();
+ fireTableCellUpdated(row,column);
}
/**
- * convertToVector
- * @param value0 TODO
- * @returns Vector
+ * Converts the data array to a Vector
.
+ *
+ * @param data the data array (null
permitted).
+ *
+ * @returns A vector (or null
if the data array
+ * is null
).
*/
protected static Vector convertToVector(Object[] data) {
if (data == null)
@@ -422,9 +564,12 @@
}
/**
- * convertToVector
- * @param value0 TODO
- * @returns Vector
+ * Converts the data array to a Vector
of rows.
+ *
+ * @param the data array (null
permitted).
+ *
+ * @returns A vector (or null
if the data array
+ * is null
.
*/
protected static Vector convertToVector(Object[][] data) {
if (data == null)
Index: javax/swing/table/TableModel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/table/TableModel.java,v
retrieving revision 1.5
diff -u -r1.5 TableModel.java
--- javax/swing/table/TableModel.java 31 Jul 2004 23:47:30 -0000 1.5
+++ javax/swing/table/TableModel.java 7 Jan 2005 18:31:43 -0000
@@ -1,5 +1,5 @@
/* TableModel.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,72 +39,96 @@
import javax.swing.event.TableModelListener;
-
/**
- * TableModel public interface
+ * A TableModel
is a two dimensional data structure that
+ * can store arbitrary Object
instances, usually for the
+ * purpose of display in a address@hidden JTable} component. Individual objects
+ * can be accessed by specifying the row index and column index for
+ * the object. Each column in the model has a name associated with it.
+ *
+ * The address@hidden DefaultTableModel} class provides one implementation of
+ * this interface.
+ *
* @author Andrew Selkirk
*/
public interface TableModel
{
/**
- * getRowCount
- * @return row count
+ * Returns the number of rows in the model.
+ *
+ * @return The row count.
*/
int getRowCount();
/**
- * getColumnCount
- * @return column count
+ * Returns the number of columns in the model.
+ *
+ * @return The column count
*/
int getColumnCount();
/**
- * getColumnName
- * @param columnIndex Column index
- * @return Column name
+ * Returns the name of a column in the model.
+ *
+ * @param columnIndex the column index.
+ *
+ * @return The column name.
*/
String getColumnName(int columnIndex);
/**
- * getColumnClass
- * @param columnIndex Column index
- * @return Column class
+ * Returns the Class
for all Object
instances
+ * in the specified column.
+ *
+ * @param columnIndex the column index.
+ *
+ * @return The class.
*/
Class getColumnClass(int columnIndex);
/**
- * isCellEditable
- * @param rowIndex Row index
- * @param columnIndex Column index
- * @return true if editable, false otherwise
+ * Returns true
if the cell is editable, and false
+ * otherwise.
+ *
+ * @param rowIndex the row index.
+ * @param columnIndex the column index.
+ *
+ * @return true
if editable, false
otherwise.
*/
boolean isCellEditable(int rowIndex, int columnIndex);
/**
- * getValueAt
- * @param rowIndex Row index
- * @param columnIndex Column index
- * @return Value at specified indices
+ * Returns the value (Object
) at a particular cell in the
+ * table.
+ *
+ * @param rowIndex the row index.
+ * @param columnIndex the column index.
+ *
+ * @return The value at the specified cell.
*/
Object getValueAt(int rowIndex, int columnIndex);
/**
- * setValueAt
- * @param aValue Value to set
- * @param rowIndex Row index
- * @param columnIndex Column index
+ * Sets the value at a particular cell in the table.
+ *
+ * @param aValue the value (null
permitted).
+ * @param rowIndex the row index.
+ * @param columnIndex the column index.
*/
void setValueAt(Object aValue, int rowIndex, int columnIndex);
/**
- * addTableModelListener
- * @param listener TableModelListener
+ * Adds a listener to the model. The listener will receive notification
+ * of updates to the model.
+ *
+ * @param listener the listener.
*/
void addTableModelListener(TableModelListener listener);
/**
- * removeTableModelListener
- * @param listener TableModelListener
+ * Removes a listener from the model.
+ *
+ * @param listener the listener.
*/
void removeTableModelListener(TableModelListener listener);
}