public int checkComponentHeight ( ) { int maxHeightToCheck = componentStartYLocation - currentLocationOnPage + pageHeight ; if ( currentComponent == null ) return 0 ; if ( currentComponent instanceof JTable ) { // todo(don) There has to be a better way of doing this JTable code. int beforeHeight = currentComponent . getHeight ( ) ; int rowHeight = ( ( JTable ) currentComponent ) . getRowHeight ( ) ; int rowCount = ( ( JTable ) currentComponent ) . getRowCount ( ) ; int maxRowCount = maxHeightToCheck / rowHeight ; for ( int i = rowCount - 1 ; i < rowCount ; i ++ ) { if ( i >= maxRowCount ) break ; // No need to go farther (yet) rowCount = ( ( JTable ) currentComponent ) . getRowCount ( ) ; } int newComponentHeight = rowHeight * rowCount ; currentComponent . setSize ( currentComponent . getWidth ( ) , newComponentHeight ) ; // Change in the height. return newComponentHeight - beforeHeight ; } return 0 ; }
Get the height of this component . Typically this is just the height of the component . Except for JTables where I need to query to this target height to make sure the component is at least this correct height .