protected void computeLineLengths ( ) { firstLineLength = - 1 ; lastLineLength = 0 ; longestLineLength = 0 ; String t = getText ( ) ; FontMetrics fm = g . getFontMetrics ( ) ; int s1 = 0 ; int s2 = t . indexOf ( ' ' ) ; int w = 0 ; do { if ( s2 == - 1 ) s2 = t . length ( ) ; else containsLineBreak = true ; w = stringWidth ( fm , t . substring ( s1 , s2 ) ) ; if ( firstLineLength == - 1 ) firstLineLength = w ; if ( w > longestLineLength ) longestLineLength = w ; s1 = s2 + 1 ; s2 = t . indexOf ( ' ' , s1 ) ; } while ( s1 < t . length ( ) && s2 < t . length ( ) ) ; lastLineLength = w ; }
Computes the lengths of the first last and longest lines .