java - Appending a String to a JTextPane -
i have question. appending string in jtextpane, chatwindow, insertstring, issue don't know how 'insertstring' jtextpane. here code:
private void showmessage(final string string){ swingutilities.invokelater( new runnable(){ public void run(){ //chatwindow.append(string); //the bottom method used appending string jtextpane style try { //doc.insertstring(0, "start of text\n", null ); //doc.insertstring(doc.getlength(), "", string ); //doc.insertstring(int offset, string str, arributeset a); //setting style string (down below) styleconstants.setforeground(keyword, color.gethsbcolor(251, 89, 87)); //styleconstants.setbackground(keyword, color.yellow); styleconstants.setbold(keyword, false); doc.insertstring(0, string, keyword); } catch(exception e) { system.out.println(e); } } } ); }
where says:
doc.insertstring(0, string, keyword);
this appending string chatwindow. issue don't know how 'insertstring' chatwindow how did in note above try-catch method:
chatwindow.append(string)
does know use 'doc.insertstring(0, string, keyword);' insert string keyword chatwindow? result of doc.insertstring doesn't show on chatwindow. thanks.
what this?
chatwindow.getdocument().insertstring(0, string, keyword);
Comments
Post a Comment