RowsCount not showing in programmatically created table

I am using 7.2.20. I want to create a table of KeyValueEntity records and attach to the screen programmatically. The table can be created and displayed but I cannot get the rowsCount field to show.

@Subscribe
public void onBeforeShow(BeforeShowEvent event) {
Table table = uiComponents.create(Table.class);

    KeyValueCollectionContainer container = dataComponents.createKeyValueCollectionContainer();

    // register properties
    container.addProperty("id", String.class);
    container.addProperty("name", String.class);

    // create entries
    ArrayList<KeyValueEntity> entities = new ArrayList<>();
    for(int i=0; i < 10; i++) {
        KeyValueEntity kv = new KeyValueEntity();
        kv.setValue("id", "" + i);
        kv.setValue("name", "Name " + i);
        entities.add(kv);
    }

    container.setItems(entities);
    table.setItems(new ContainerTableItems<>(container));
    table.setWidthFull();
    table.setHeight("400px");

    RowsCount rowsCount = uiComponents.create(RowsCount.class);
    rowsCount.setRowsCountTarget(table);
    rowsCount.setTotalCountDelegate(x -> new Long(entities.size()));
    rowsCount.setAutoLoad(true);
    table.setRowsCount(rowsCount);

    box.add(table);
}

What is the problem ?