DevFaqEditorHowToReuseEditorHighlighting

I you don't want to open or edit your data in a new editor TopComponent, but you still want to have nice syntax coloring in your own editor, you can get the EditorKit for the mime type and reuse it in your own JEditorPane.

For example, if you want to nicely display some XML in your own JEditorPane then first make sure all the required modules are loaded then:

String mime = "text/xml";
EditorKit ek = CloneableEditorSupport.getEditorKit(mime);
editorPane.setEditorKit(ek);
editorPane.setContentType(mime);
editorPane.setText(xml);

And you will get nice syntax coloring. However you won't get line numbers and other editing facilities since they are not provided by the EditorKit.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo