Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help,how to improve JTextPane's efficiency?

 
zhijie dong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
such as:

if there have 20 thousand rows,how to do?



StyledDocument doc=new StyledDocument();
JTextPane textPane=new JTextPane(doc);

Style errorStyle=textpane.addStyle(null,null);
StyleConstants.setForeground(defaultStyle,Color.RED);

Style infoStyle=textpane.addStyle(null,null);
StyleConstants.setForeground(infoStyle,Color.BLUE);

int count=1;
while(true){
doc.insertString(doc.getLength(), ""+count, errorStyle);
doc.insertString(doc.getLength(), ""+count, infoStyle);
count++;
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic