List of usage examples for javax.swing.text StyledDocument setLogicalStyle
public void setLogicalStyle(int pos, Style s);
From source file:homenetapp.HomeNetAppGui.java
private void updateTextPane(final String text, final javax.swing.text.Style color) { SwingUtilities.invokeLater(new Runnable() { public void run() { javax.swing.text.StyledDocument doc = consoleTextPane.getStyledDocument(); try { // consoleTextPane.se if (color != null) { doc.setLogicalStyle(doc.getLength(), color); }/*from w w w . ja va 2 s . co m*/ doc.insertString(doc.getLength(), text, null); if (doc.getLength() > 10000) { doc.remove(0, text.length()); } } catch (javax.swing.text.BadLocationException e) { throw new RuntimeException(e); } consoleTextPane.setCaretPosition(doc.getLength() - 1); } }); }