• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need to write text directly to a JTextPane  RSS feed

 
Sivapraveen Chandana
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am developing a small tool which reads certain paragraphs of text(which occupy more than one display window)from log files present in a remote unix server. When the user enters a search string into a textfield and clicks a button, it fetches the data into a string again and again and needs to add it directly to the textpane and the textpane needs to be set to visible for the user i.e. it must appear when the user clicks the button.
Please advise how to continuously add text directly to the textpane. Any help will be appreciated.

Thanks in advance..
Praveen.
 
Brian Cole
Author
Ranch Hand
Posts: 932
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sivapraveen Chandana:
Please advise how to continuously add text directly to the textpane.


Since you're going to be doing this a lot, you probably want to keep a reference to the Document.
Document yourDoc = yourTextPane.getDocument();

Then simply call
yourDoc.insertString(yourDoc.getLength(), newText, null);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!