Table Bean -- A High-Performance Java Data Grid Component
New: Images in Table Cells
I've just released version 1.2.0 of the TableBean. This is a very basic Swing port of the original Java 1 Table bean.
Swing has its own table classes (JTable). They are more powerful and flexible
than this Table bean . Moreover, they are part of the standard Java 2 API. It thus makes sense to use JTable whenever you need a table in Java 2 projects. However, I've ported my Table to Java 2 Swing
because I wanted to run old code under Java 2 which relied on it. In addition to that, for certain project requirements, Table bean's superior scrolling and screen drawing performance
and lower memory requirements may be an advantage.
This Java bean is free software. It is being released unter the Gnu Lesser General Public License.
The Table bean is a fast, flexible, multi-column data grid.
Among other features, it supports:
- Multi-thread safety and support for efficient display and scrolling of table data while the table data Vector is being
grown, shrunk or updated in a separate thread.
- High speed vertical and horizontal scrolling.
- Designed to handle thousands of rows.
- Efficient integration with client code, minimizing the duplication of table data. By implementing
TableRow Interface, a client application can make its data available to the
table Bean with minimal table initialization and memory overhead.
- Per-column font, font size and style.
- Per-cell foreground and background color with zero overhead if the default colors are used.
- Mouse-resizeable columns with wrapping column titles.
- Various string alignment and formatting options -- left aligned, centered, right aligned, decimal alignment, tab support.
- Four selection modes -- Exactly one, zero or one, multiple continuous, multiple non-continuous.
- An optional reference column containing, for each row, a checkbox and/or line number.
- Automatic column-width adjustment based on displayed data.
- Custom border painting for column titles, reference column cells and the table as a whole.
- Support for context menues.
- As of version 1.0.2, primitive support for wrapping data cells.
- As of version 1.1, sortable columns, column width adjustment based on the overall width of the table and
fixed size (non resizable) columns.
Note: if you experience problems running the applets below it's most likely because you're
using an old or
incompatible Java Virtual Machine. The bean has been developed under IBM VisualAge
for Java 2.0 and
went through a reasonable amount of testing (under VisualAge, Sun's
JRE 1.1.7B, IBM's JRE 1.1.7B and various browsers). Some older browsers have trouble handling the scrollbars
correctly. For best results use the Java Plug-In versions of the demo applets.
The following samples demonstrate the Swing port of the Table Bean. They run in the Java Plugin and have been tested under JDK 1.2.2.
Downloading the Table Bean
Note: I've had problems downloading JAR files with both Netscape and IE in the past. If one of the JAR files below gets corrupted
during the download, try downloading it with a different browser or ajdust your browser's file type settings. (On my Windows NT machine, IE 5 downloads the files correctly using IE's default option settings.)
The classical Java 1 (no Swing) Table Bean version:
And here's the Swing port:
Documentation and Demo Code
And for the Swing port:
- Demo applet source file. (Implements main()
and can also be run as a Java application from the command line.
Pass one of the "demo_kind" applet parameters as the first command line argument in application mode.
Check out the applet info for the list of available values.)
- ColorTableRow class. Required for the "Madness" demo. Calculates random cell colors.
- jared Javadoc Documentation
Images in Table Cells
This is some sample code showing how to display images in table cells.
In order to compile the code, you'll need the two classes "ImageFormatter" and "ImageMap". Here they are:
Known Problems and Bugs
- Don't use the one argument constructor of the Table class. This constructor assumes exactly one ColumnDefinition in
columnDefinitions argument vector. Use the two argument constructor instead and pass an empty Vector as the
if you haven't got any rows to display yet.