KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > admin > common > TextPaneUpdater


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.admin.common;
5
6 import javax.swing.JTextPane JavaDoc;
7 import javax.swing.text.Document JavaDoc;
8
9 public class TextPaneUpdater implements Runnable JavaDoc {
10   JTextPane JavaDoc m_view;
11   String JavaDoc m_line;
12
13   static final String JavaDoc LINE_SEP = System.getProperty("line.separator");
14     
15   public TextPaneUpdater(JTextPane JavaDoc view) {
16     m_view = view;
17   }
18     
19   public TextPaneUpdater(JTextPane JavaDoc view, String JavaDoc text) {
20     this(view);
21     setLine(text);
22   }
23   
24   void setLine(String JavaDoc line) {
25     m_line = line;
26   }
27     
28   public void run() {
29     Document JavaDoc 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 JavaDoc e) {/**/}
35   }
36 }
37
Popular Tags