columnIndex++;
columnIndex += item.colSpan;  columnIndex++;
	protected void initContent(int firstLineWidth, int lineWidth) {		//#debug		System.out.println("Container: intialising content for " + this + ": autofocus=" + this.autoFocusEnabled);		Item[] myItems = (Item[]) this.itemsList.toArray( new Item[ this.itemsList.size() ]);		this.items = myItems;		if (this.autoFocusEnabled && this.autoFocusIndex >= myItems.length ) {			this.autoFocusIndex = 0;		}		//#ifdef polish.css.view-type			if (this.view != null) {				if (this.autoFocusEnabled) {					//#debug					System.out.println("Container/View: autofocusing element " + this.autoFocusIndex);					this.autoFocusEnabled = false;					if (this.autoFocusIndex < myItems.length ) {						Item item = myItems [ this.autoFocusIndex ];						if (item.appearanceMode != Item.PLAIN) {							focus( this.autoFocusIndex, item, 0 );								}					}				}				this.view.initContent(this, firstLineWidth, lineWidth);				this.contentWidth = this.view.contentWidth;				this.contentHeight = this.view.contentHeight;				this.appearanceMode = this.view.appearanceMode;				return;			}		//#endif					//#ifdef tmp.useTable		if (this.columnsSetting == NO_COLUMNS || myItems.length <= 1) {		//#endif			int myContentWidth = 0;			int myContentHeight = 0;			boolean hasFocusableItem = false;			for (int i = 0; i < myItems.length; i++) {				Item item = myItems[i];				//System.out.println("initalising " + item.getClass().getName() + ":" + i);				int width = item.getItemWidth( firstLineWidth, lineWidth );				int height = item.getItemHeight( firstLineWidth, lineWidth );				// now the item should have a style, so it can be safely focused				// without loosing the style information:				if (item.appearanceMode != PLAIN) {					hasFocusableItem = true;				}				if (this.autoFocusEnabled  && (i >= this.autoFocusIndex ) && (item.appearanceMode != Item.PLAIN)) {					//#debug					System.out.println("Container: autofocusing element " + i);					this.autoFocusEnabled = false;					focus( i, item, 0 );					height = item.getItemHeight( firstLineWidth, lineWidth );					width = item.getItemWidth( firstLineWidth, lineWidth );				}				if (width > myContentWidth) {					myContentWidth = width; 				}				myContentHeight += height + this.paddingVertical;			}			if (!hasFocusableItem) {				this.appearanceMode = PLAIN;			} else {				this.appearanceMode = INTERACTIVE;			}					this.contentHeight = myContentHeight;			this.contentWidth = myContentWidth;			return;		//#ifdef tmp.useTable		}		//#endif				//#ifdef tmp.useTable			// columns are used			boolean isNormalWidthColumns = (this.columnsSetting == NORMAL_WIDTH_COLUMNS);			if (this.columnsSetting != STATIC_WIDTH_COLUMNS) {				int availableColumnWidth;				if (isNormalWidthColumns) {					// this.columnsSetting == NORMAL_WIDTH_COLUMNS					// each column should use as much space as it can use					// without ousting the other columns					// (the calculation will be finished below)					availableColumnWidth = lineWidth - ((this.numberOfColumns -1) * this.paddingHorizontal);				} else {					// each column should take an equal share					availableColumnWidth = 						(lineWidth - ((this.numberOfColumns -1) * this.paddingHorizontal))						/ this.numberOfColumns;				}				//System.out.println("available column width: " + availableColumnWidth );				this.columnsWidths = new int[ this.numberOfColumns ];				for (int i = 0; i < this.numberOfColumns; i++) {					this.columnsWidths[i] = availableColumnWidth;				}			} else {				int restWidth = 0;				int dynamicColumnIndex = -1;				for (int i = 0; i < this.numberOfColumns; i++) {					int w = this.columnsWidths[i];					if (w == -1) {						dynamicColumnIndex = i;					} else {						restWidth += w;					}				}				if (dynamicColumnIndex != -1) {					this.columnsWidths[ dynamicColumnIndex ] = lineWidth - restWidth;				}			}			this.numberOfRows = (myItems.length / this.numberOfColumns) + (myItems.length % 2);			this.rowsHeights = new int[ this.numberOfRows ];			int maxRowHeight = 0;			int columnIndex = 0;			int rowIndex = 0;			int[] maxColumnWidths = null;			if (isNormalWidthColumns) {				maxColumnWidths = new int[ this.numberOfColumns ];			}			int maxWidth = 0; // important for "equal" columns-width			int myContentHeight = 0;			//System.out.println("starting init of " + myItems.length + " container items.");			for (int i=0; i< myItems.length; i++) {				Item item = myItems[i];				int availableWidth = this.columnsWidths[columnIndex];				//System.out.println("available with: " + availableWidth);				int width = item.getItemWidth( availableWidth, availableWidth );				//System.out.println("got item width");				int height = item.getItemHeight( availableWidth, availableWidth );								// now the item should have a style, so it can be safely focused				// without loosing the style information:				if (this.autoFocusEnabled  && (i >= this.autoFocusIndex ) && (item.appearanceMode != Item.PLAIN)) {					//#debug					System.out.println("Container: Autofocusing item " + i );					this.autoFocusEnabled = false;					focus( i, item, 0 );					height = item.getItemHeight( availableWidth, availableWidth );					width = item.getItemWidth( availableWidth, availableWidth );				}								if (height > maxRowHeight) {					maxRowHeight = height;				}				if (isNormalWidthColumns && width > maxColumnWidths[columnIndex ]) {					maxColumnWidths[ columnIndex ] = width;				}				if (width > maxWidth ) {					maxWidth = width;				}				columnIndex++;				if (columnIndex == this.numberOfColumns) {					//System.out.println("starting new row: rowIndex=" + rowIndex + "  numberOfRows: " + numberOfRows);					columnIndex = 0;					this.rowsHeights[rowIndex] = maxRowHeight;					myContentHeight += maxRowHeight + this.paddingVertical;					maxRowHeight = 0;					rowIndex++;				}			} // for each item			// now save the worked out dimensions:			if (isNormalWidthColumns) {				// Each column should use up as much space as 				// needed in the "normal" columns-width mode.				// Each column which takes less than available 				// the available-row-width / number-of-columns				// can keep, but the others might need to be adjusted,				// in case the complete width of the table is wider				// than the allowed width.								int availableRowWidth = lineWidth - ((this.numberOfColumns -1) * this.paddingHorizontal);				int availableColumnWidth = availableRowWidth / this.numberOfColumns;				int usedUpWidth = 0;				int leftColumns = this.numberOfColumns;				int completeWidth = 0;				for (int i = 0; i < maxColumnWidths.length; i++) {					int maxColumnWidth = maxColumnWidths[i];					if (maxColumnWidth <= availableColumnWidth) {						usedUpWidth += maxColumnWidth;						leftColumns--;					}					completeWidth += maxColumnWidth;				}				if (completeWidth <= availableRowWidth) {					// okay, the table is fine just how it is					this.columnsWidths = maxColumnWidths;				} else {					// okay, some columns need to be adjusted:					// re-initialise the table:					int leftAvailableColumnWidth = (availableRowWidth - usedUpWidth) / leftColumns;					int[] newMaxColumnWidths = new int[ this.numberOfColumns ];					myContentHeight = 0;					columnIndex = 0;					rowIndex = 0;					maxRowHeight = 0;					maxWidth = 0;					//System.out.println("starting init of " + myItems.length + " container items.");					for (int i = 0; i < myItems.length; i++) {						Item item = myItems[i];						int width = item.itemWidth;						int height = item.itemHeight;						if (maxColumnWidths[ columnIndex ] <= availableColumnWidth) {							newMaxColumnWidths[ columnIndex ] = maxColumnWidths[ columnIndex ];						} else {							// re-initialise this item,							// if it is wider than the left-available-column-width							if ( width > leftAvailableColumnWidth ) {								item.isInitialised = false;								width = item.getItemWidth( leftAvailableColumnWidth, leftAvailableColumnWidth );								height = item.getItemHeight( leftAvailableColumnWidth, leftAvailableColumnWidth );							}							if (width > newMaxColumnWidths[ columnIndex ]) {								newMaxColumnWidths[ columnIndex ] = width;							}						}						if (height > maxRowHeight) {							maxRowHeight = height;						}						columnIndex++;						if (columnIndex == this.numberOfColumns) {							//System.out.println("starting new row: rowIndex=" + rowIndex + "  numberOfRows: " + numberOfRows);							columnIndex = 0;							this.rowsHeights[rowIndex] = maxRowHeight;							myContentHeight += maxRowHeight + this.paddingVertical;							maxRowHeight = 0;							rowIndex++;						}					} // for each item							this.columnsWidths = newMaxColumnWidths;				}			} else if (this.columnsSetting == EQUAL_WIDTH_COLUMNS) {				// Use the maximum used column-width for each column,				// unless this table should be expanded, in which				// case the above set widths  will be used instead.				if (!this.isLayoutExpand) {					for (int i = 0; i < this.columnsWidths.length; i++) {						this.columnsWidths[i] = maxWidth;					}				}			} // otherwise the column widths are defined statically.			// set content height & width:			int myContentWidth = 0;			for (int i = 0; i < this.columnsWidths.length; i++) {				myContentWidth += this.columnsWidths[i] + this.paddingHorizontal;			}			this.contentWidth = myContentWidth;			this.contentHeight = myContentHeight;		//#endif	}