public static boolean trimTALength(final JTextComponent ta) {
		boolean atEnd = false;
		int length = ta.getDocument().getLength();
		
		int caretPosition = ta.getCaretPosition();
		try {
			if (length > 800000) {
				int subtracted = length/2;
				int newLength = length - subtracted;
				ta.setText(ta.getText(subtracted, newLength));
				caretPosition = Math.max(0, caretPosition - subtracted);
				
				length = newLength;
				ta.setCaretPosition(caretPosition);
			}
		} catch (BadLocationException e) {
		}
		if (length == caretPosition) {
			atEnd = true;
		}
		return atEnd;
	}