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

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -