¿Cómo puedo configurar el color del texto parcial en JTextArea?

Quiero establecer el color para líneas específicas en el área de texto. Lo que he encontrado hasta ahora, es lo siguiente

// Declarations
private final DefaultStyledDocument document;
private final MutableAttributeSet homeAttributeSet;
private final MutableAttributeSet awayAttributeSet;

// Usage in the form constructor
jTextAreaLog.setDocument(document);
homeAttributeSet = new SimpleAttributeSet();
StyleConstants.setForeground(homeAttributeSet, Color.blue);
StyleConstants.setItalic(homeAttributeSet, true);
awayAttributeSet = new SimpleAttributeSet();
StyleConstants.setForeground(awayAttributeSet, Color.red);

// Setting the style of the last line
final int start = jTextAreaLog.getLineStartOffset(jTextAreaLog.getLineCount() - 2);
final int length = jTextAreaLog.getLineEndOffset(jTextAreaLog.getLineCount() - 1) -     start;
document.setCharacterAttributes(start, length, awayAttributeSet, true);

Pero esto no está funcionando. ¿Qué estoy haciendo mal?

EDITAR: OK, he estado probando cosas e intenté usar

final int end = jTextAreaLog.getLineEndOffset(jTextAreaLog.getLineCount() - 1);
document.insertString(end, "someText", awayAttributeSet);

para agregar texto en lugar de agregar y rediseñar, pero fue en vano.

Respuestas a la pregunta(2)

Su respuesta a la pregunta