public void scroll(int amount, int maxKeep) {
        index += amount;
        if (index < 0)
            index = 0;
        if (index == 0 || container.size() <= maxKeep)
            return;
        if (index >= container.size())
            index = container.size() - 1;
        if (index > container.size() - maxKeep - 1)
            index = container.size() - maxKeep - 1;
    }