int lastIndex = items[row].length - 1; CoolItem lastItem = items[row][lastIndex]; if (lastItem.preferredWidth != -1) { Rectangle bounds = lastItem.getBounds(); bounds.width = lastItem.preferredWidth; lastItem.requestedWidth = lastItem.preferredWidth; lastItem.setBounds(bounds.x, bounds.y, bounds.width, bounds.height); }
void createItem (CoolItem item, int index) {	int itemCount = getItemCount(), row = 0;	if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);	if (items.length == 0) {		items = new CoolItem[1][1];		items[0][0] = item;		}	else {		int i = index;		/* find the row to insert into */		if (index < itemCount) {			while (i > items[row].length) {				i -= items[row].length;				row++;			}   		}		else {			row = items.length - 1;			i = items[row].length;			}		int oldLength = items[row].length;		CoolItem[] newRow = new CoolItem[oldLength + 1];		System.arraycopy(items[row], 0, newRow, 0, i);		newRow[i] = item;		System.arraycopy(items[row], i, newRow, i + 1, oldLength - i);		items[row] = newRow;	}	item.requestedWidth = CoolItem.MINIMUM_WIDTH;	layoutItems();	int length = originalItems.length;	CoolItem [] newOriginals = new CoolItem [length + 1];	System.arraycopy (originalItems, 0, newOriginals, 0, index);	System.arraycopy (originalItems, index, newOriginals, index + 1, length - index);	newOriginals [index] = item;	originalItems = newOriginals;}