JTextPane pane = new JTextPane();
pane.setContentType("text/html");
pane.setText(
"<font color = blue>Hallo</font> <a href>dies ist ein Test</a><font color=yellow>Dieses
Element sollte seine Farbe durch HTML bekommen haben</font>");
add(pane);
SimpleAttributeSet attributeSet = new SimpleAttributeSet();
SimpleAttributeSet attributeSet2 = new SimpleAttributeSet();
SimpleAttributeSet attributeSet3 = new SimpleAttributeSet();
StyleConstants.setForeground(attributeSet, Color.RED);
StyleConstants.setForeground(attributeSet2, Color.GREEN);
StyleConstants.setForeground(attributeSet3, Color.CYAN);
StyleConstants.setBold(attributeSet, true);
StyleConstants.setItalic(attributeSet, true);
StyleConstants.setFontSize(attributeSet, 20);
StyledDocument doc = pane.getStyledDocument();
doc.setCharacterAttributes(0, 5, attributeSet, false);
doc.setCharacterAttributes(7, doc.getLength()-7, attributeSet2, false);
doc.setCharacterAttributes(5, 2, attributeSet3, false);