Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void append(JTextPane j, Color c, String s) { // better implementation--uses
- // StyleContext
- StyleContext sc = StyleContext.getDefaultStyleContext();
- AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY,StyleConstants.Foreground, c);
- int len = j.getDocument().getLength(); // same value as
- // getText().length();
- j.setCaretPosition(len); // place caret at the end (with no selection)
- j.setCharacterAttributes(aset, false);
- j.replaceSelection(s); // there is no selection, so inserts at caret
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement