public static void trimLines(final Document doc,final int lineCount){
  if (doc.getLength() < lineCount) {
    return;
  }
  try {
    final String text=doc.getText(0,doc.getLength());
    int returnsFound=0;
    for (int i=text.length() - 1; i >= 0; i--) {
      if (text.charAt(i) == '\n') {
        returnsFound++;
      }
      if (returnsFound == lineCount) {
        doc.remove(0,i);
        return;
      }
    }
  }
 catch (  final BadLocationException e) {
    ClientLogger.logError("There was an Error whilst trying trimming Chat",e);
  }
}

public static void trimLines ( final Document doc , final int lineCount ) { if ( doc . getLength ( ) < lineCount ) { return ; } try { final String text = doc . getText ( 0 , doc . getLength ( ) ) ; int returnsFound = 0 ; for ( int i = text . length ( ) - 1 ; i >= 0 ; i -- ) { if ( text . charAt ( i ) == '\n' ) { returnsFound ++ ; } if ( returnsFound == lineCount ) { doc . remove ( 0 , i ) ; return ; } } } catch ( final BadLocationException e ) { ClientLogger . logError ( "There was an Error whilst trying trimming Chat" , e ) ; } }
show only the first n lines
