1 4 package com.tc.admin.common; 5 6 import javax.swing.JTextPane ; 7 import javax.swing.text.Document ; 8 9 public class TextPaneUpdater implements Runnable { 10 JTextPane m_view; 11 String m_line; 12 13 static final String LINE_SEP = System.getProperty("line.separator"); 14 15 public TextPaneUpdater(JTextPane view) { 16 m_view = view; 17 } 18 19 public TextPaneUpdater(JTextPane view, String text) { 20 this(view); 21 setLine(text); 22 } 23 24 void setLine(String line) { 25 m_line = line; 26 } 27 28 public void run() { 29 Document doc = m_view.getDocument(); 30 31 try { 32 doc.insertString(doc.getLength(), m_line+LINE_SEP, null); 33 m_view.setCaretPosition(doc.getLength()-1); 34 } catch(Exception e) {} 35 } 36 } 37 | Popular Tags |