Reputation: 55
I want to create simple TextEditor program that find all 'a' characters in String and change color to red.I can find 'a' characters so i just need to change color.If it is not possible in java , can i do this in c++(QT Lib.)?
Upvotes: 1
Views: 107
Reputation: 825
JEditor Pane in Java support HTML and CSS. So put html and css code for anything you want like changing color, bold and italic etc.
pane = new JEditorPane();
pane.setContentType("text/html");
you can write html and inline css directly.
For advance level you can also use HTMLEditorKit class for adding css.
HTMLEditorKit kit = new HTMLEditorKit();
jEditorPane.setEditorKit(kit);
StyleSheet styleSheet = kit.getStyleSheet();
styleSheet.addRule("body {color:#000; font-family:times; margin: 4px; }");
styleSheet.addRule("h1 {color: blue;}");
styleSheet.addRule("h2 {color: #ff0000;}");
styleSheet.addRule("pre {font : 10px monaco; color : black; background-color : #fafafa; }");
I hope I helped you.
Upvotes: 1