java - JEditorKit color single chars without html -
i want mark parts of jeditorpane content color, without using html type content type. there way accomplish this, maybe playing around document?
without using html type content type
this means have plan text file , should using jtextpane. can use attributes color text.
jtextpane textpane = new jtextpane(); textpane.settext("some text text pane."); styleddocument doc = textpane.getstyleddocument(); simpleattributeset keyword = new simpleattributeset(); styleconstants.setforeground(keyword, color.red); styleconstants.setbackground(keyword, color.yellow); styleconstants.setbold(keyword, true); // color existing text doc.setcharacterattributes(0, 5, keyword, false); // add text try { doc.insertstring(doc.getlength(), "\nend of text", keyword ); } catch(exception e) { system.out.println(e); }
Comments
Post a Comment