ArrayContainer wrapper

I’ve been thinking of publishing this simple, yet often useful wrapper for a while. And damn, Sami made
an almost identical wrapper
today as well… :huh:

Anyhow, here’s my version. You can use it easily, for example:

    // An array
    Integer[] numbers = {4, 8, 15, 16, 23, 42};
    // The wrapper
    ArrayContainer<Integer> numberCtn = new ArrayContainer<Integer> (numbers);

    // The column property ID is used by Table as the default for
    // column header. It is by default "0".

    // Use the wrapper as the data source for the table
    Table numbersTbl = new Table("Integers", numberCtn);

See the

11230.jar (6.94 KB)

I added a
class suggested by Sami. It allows fully dynamic generation of container data from a callback interface. It’s also a much easier alternative to
for calculating the values of one column from another.

// 100,000 rows and 2 columns
LazyContainer lazydata = new LazyContainer(100000, 2, new LazyContainer.Provider() {
    public Object getData(int row, int column) {
        if (column == 0)
            return row;
        else if (column == 1)
            return ((double)row)*((double)row);
            return null;
Table table = new Table("Data from a Lazy Container", lazydata);
table.setColumnHeaders(new String[] {"Index", "Power of Index"});

Notice that a Table is unable to hold more than about 500,000 items. The exact limit depends on the font size, because the table content is rendered as a very tall HTML layer.

For more details, see the:



Project home page


Online Demo


API Documentation

is included in the new [tt]

for the above mentioned 500.000 rows limitation.