This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clearing JTextPane's Document!

 
Vic Hunting
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys,
How do I clear a document associated with JTextPane?
I have a JTextPane displaying an html file which gets updated every second.
The way I have it below works brilliantly (doesn't flicker whatsoever) except that new content gets appended to the previous content.
Is there a way to clear the document just before the next iteration?
cheers
:vic

private class PageLoader extends TimerTask {
public PageLoader(){}
public void run() {
try {
//html is an instance of JTextPane
Document docs = html.getDocument();
InputStream input = new URL(string).openStream();
html.getEditorKit().read(input, docs, docs.getLength());

Thread.sleep(1000);
//Clear the document here:
}catch( Exception e ){
e.printStackTrace();
}
}
}
}
 
Joe Ess
Bartender
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yourJTextPane.setText("");
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic