JTable |
Other Swing Changes |
As a result of JTable changes, code written for v 1.2 or for JFC/Swing 1.1 might have the following problems when run in v 1.3:
- Since the
TableColumn
getHeaderRenderer
method now returns null by default, you can't use that method to get the default header renderer. Instead, change your code to use theJTableHeader
getDefaultRenderer
method. See How to Use Tables in The Java Tutorial for an example.- Because JTable's default text editor is now smarter about data types, it now gives
setValueAt
objects of the appropriate type, instead of always specifying strings. For example, ifsetValueAt
is invoked for an Integer cell, then the value is specified as an Integer instead of a String. If you implemented a table model, then you might have to change itssetValueAt
method to take the new data type into account. If you implemented a class used as a data type for cells, make sure that your class has a constructor that takes a single String argument.Column and Row Layout Improvements
We made the following changes:
- Improved performance in tables with large numbers of columns
Moving the header renderers from the columns themselves to the table header represents the most significant change to performance and footprint by sharing similar header renderers on a per-table basis.- Dynamic changing of individual row height
The rendering machinery in the JTable has been substantially overhauled in this release to enable this much sought after feature in the JTable.- Simplified creation of non-standard editor components
TheAbstractCellEditor
class has been included in response to continued feedback on the difficulty of creating non-standard editor components.- Better handling of inter-cell spacing
Previously JTable did not correctly implement its specification for inter-cell spacing. Changes in the inter-cell spacing affected a number of other properties including the overall height of the table. In v 1.3, the inter-cell spacing has only one effect: to provide an inset for the cells, where the inset is the amount that renderers and editors are shrunk to accommodate the spacing between the cells.For more information, see the API documentation for the following methods and fields. Note that "obsolete" means that you should avoid using the obsolete API, but that using the API isn't dangerous enough to warrant a compile-time warning. "Deprecated" API, on the other hand, is not only obsolete but also results in a compile-time warning.
In JTable
public void removeNotify()
protected void unconfigureEnclosingScrollPane()
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
protected boolean cellSelectionEnabled
// obsoletepublic void setRowHeight(int row, int height)
public int getRowHeight(int row)
In JTableHeader
protected boolean updateTableInRealTime
// obsoletepublic boolean getUpdateTableInRealTime()
// obsoletepublic void setUpdateTableInRealTime(boolean flag)
// obsoletepublic void setDefaultRenderer(TableCellRenderer defaultRenderer)
public TableCellRenderer getDefaultRenderer()
protected TableCellRenderer createDefaultRenderer()
In TableColumn
public final static String COLUMN_WIDTH_PROPERTY;
// obsoletepublic final static String HEADER_VALUE_PROPERTY;
// obsoletepublic final static String HEADER_RENDERER_PROPERTY
// obsoletepublic final static String CELL_RENDERER_PROPERTY
// obsoleteprotected TableCellRenderer createDefaultHeaderRenderer()
transient protected int resizedPostingDisableCount
// deprecatedpublic void disableResizedPosting()
// deprecatedpublic void enableResizedPosting()
//deprecatedNew Class:
javax.swing.AbstractCellEditor
Existing Class
DefaultCellEditor
now extendsAbstractCellEditor
New SizeSequence Utility Class
Before this release the height of rows in a JTable was always fixed. Introducing variable height rows whilst retaining the scalability requirements of the JTable (no O(N) behavior on rows) has required this new class and we have made it public as we think it may be generally useful. Indeed, table columns and the variable height rows of a JList might both use this class in the future to improve performance.
Copyright © 1995-98 Sun Microsystems, Inc. All Rights Reserved. Please send comments to: swing-feedback@java.sun.com. This is not a subscription list. |
Java Software |