int iAvailableItems = Math.min(iVisibleCount, elPaletteEntries.size() - iStartIndex);
    public void mouseDown(MouseEvent mev)    {        int iClickedY = mev.y;        int iStartIndex = iViewY / iItemHeight;        if (iStartIndex < 0)        {            iStartIndex = 0;        }        int iAvailableItems = Math.min(iVisibleCount, elPaletteEntries.size() - iStartIndex);        int iY = -(iViewY % iItemHeight);        int iClickedIndex = iStartIndex + (iClickedY - iY) / iItemHeight;        if (iClickedIndex < 0 || iClickedIndex > elPaletteEntries.size())        {            return;        }        iSelectedIndex = iClickedIndex;        coPaletteEntries.redraw();    }