}  int myContentWidth = 0; for (int i = 0; i < this.columnsWidths.length; i++) { myContentWidth += this.columnsWidths[i] + this.paddingHorizontal; } this.contentWidth = myContentWidth; this.contentHeight = myContentHeight; System.out.println("done intialising container");
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 = new int[ this.numberOfColumns ]; boolean trackColumnWidths = (this.columnsSetting == NORMAL_WIDTH_COLUMNS); int maxWidth = 0; int myContentHeight = 0;  for (int i=0; i< myItems.length; i++) { Item item = myItems[i]; int availableWidth = this.columnsWidths[columnIndex];  int width = item.getItemWidth( availableWidth, availableWidth );  int height = item.getItemHeight( availableWidth, availableWidth );    if (this.focusFirstElement && (item.appearanceMode != Item.PLAIN)) { focus( i, item ); height = item.getItemHeight( availableWidth, availableWidth ); width = item.getItemWidth( availableWidth, availableWidth ); this.focusFirstElement = false; }  if (height > maxRowHeight) { maxRowHeight = height; } if (trackColumnWidths && width > maxColumnWidths[columnIndex ]) { maxColumnWidths[ columnIndex ] = width; } if (width > maxWidth ) { maxWidth = width; } columnIndex++; if (columnIndex == this.numberOfColumns) {  columnIndex = 0; this.rowsHeights[rowIndex] = maxRowHeight; myContentHeight += maxRowHeight + this.paddingVertical; maxRowHeight = 0; rowIndex++; } }  if (this.columnsSetting == NORMAL_WIDTH_COLUMNS) { this.columnsWidths = maxColumnWidths; } else if (this.columnsSetting == EQUAL_WIDTH_COLUMNS) { if (!this.isLayoutExpand) { for (int i = 0; i < this.columnsWidths.length; i++) { this.columnsWidths[i] = maxWidth; } } }  int myContentWidth = 0; for (int i = 0; i < this.columnsWidths.length; i++) { myContentWidth += this.columnsWidths[i] + this.paddingHorizontal; } this.contentWidth = myContentWidth; this.contentHeight = myContentHeight;
	protected void initContent(int firstLineWidth, int lineWidth) {		Item[] myItems = (Item[]) this.itemsList.toArray( new Item[ this.itemsList.size() ]);		this.items = myItems;		if (this.columnsSetting == NO_COLUMNS || myItems.length <= 1) {			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.focusFirstElement && (item.appearanceMode != Item.PLAIN)) {					//System.out.println("focusing item");					focus( i, item );					height = item.getItemHeight( firstLineWidth, lineWidth );					width = item.getItemWidth( firstLineWidth, lineWidth );					this.focusFirstElement = false;				}				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;		} 		// columns are used		if (this.columnsSetting != STATIC_WIDTH_COLUMNS) {			int 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;			}		}		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 = new int[ this.numberOfColumns ];		boolean trackColumnWidths = (this.columnsSetting == NORMAL_WIDTH_COLUMNS);		int maxWidth = 0;		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.focusFirstElement && (item.appearanceMode != Item.PLAIN)) {				focus( i, item );				height = item.getItemHeight( availableWidth, availableWidth );				width = item.getItemWidth( availableWidth, availableWidth );				this.focusFirstElement = false;			}						if (height > maxRowHeight) {				maxRowHeight = height;			}			if (trackColumnWidths && 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 (this.columnsSetting == NORMAL_WIDTH_COLUMNS) {			this.columnsWidths = maxColumnWidths;		} else if (this.columnsSetting == EQUAL_WIDTH_COLUMNS) {			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;		System.out.println("done intialising container");	}