1*cdf0e10cSrcweir import javax.swing.JEditorPane; 2*cdf0e10cSrcweir import javax.swing.event.HyperlinkListener; 3*cdf0e10cSrcweir import javax.swing.event.HyperlinkEvent; 4*cdf0e10cSrcweir import javax.swing.text.Document; 5*cdf0e10cSrcweir import java.net.URL; 6*cdf0e10cSrcweir 7*cdf0e10cSrcweir class TextLogger 8*cdf0e10cSrcweir extends JEditorPane 9*cdf0e10cSrcweir { 10*cdf0e10cSrcweir public TextLogger () 11*cdf0e10cSrcweir throws java.io.IOException 12*cdf0e10cSrcweir { 13*cdf0e10cSrcweir // maDocument = getEditorKit().createDefaultDocument(); 14*cdf0e10cSrcweir super ("http://localhost"); 15*cdf0e10cSrcweir try 16*cdf0e10cSrcweir { 17*cdf0e10cSrcweir // setPage (new URL ("http://www.spiegel.de")); 18*cdf0e10cSrcweir } 19*cdf0e10cSrcweir catch (Exception e) 20*cdf0e10cSrcweir {} 21*cdf0e10cSrcweir 22*cdf0e10cSrcweir setEditable (false); 23*cdf0e10cSrcweir final JEditorPane finalPane = this; 24*cdf0e10cSrcweir addHyperlinkListener (new HyperlinkListener() 25*cdf0e10cSrcweir { 26*cdf0e10cSrcweir public void hyperlinkUpdate (HyperlinkEvent e) 27*cdf0e10cSrcweir { 28*cdf0e10cSrcweir try 29*cdf0e10cSrcweir { 30*cdf0e10cSrcweir if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) 31*cdf0e10cSrcweir finalPane.setPage (e.getURL()); 32*cdf0e10cSrcweir } 33*cdf0e10cSrcweir catch (java.io.IOException ex) 34*cdf0e10cSrcweir { 35*cdf0e10cSrcweir ex.printStackTrace(System.err); 36*cdf0e10cSrcweir } 37*cdf0e10cSrcweir } 38*cdf0e10cSrcweir }); 39*cdf0e10cSrcweir } 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir public void appendText (String sText) 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir try 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir maDocument.insertString (maDocument.getLength(), sText, null); 46*cdf0e10cSrcweir } 47*cdf0e10cSrcweir catch (javax.swing.text.BadLocationException e) 48*cdf0e10cSrcweir {} 49*cdf0e10cSrcweir } 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir private Document maDocument; 52*cdf0e10cSrcweir } 53