DevFaqEditorHowToReuseEditorHighlighting

(Difference between revisions)
Jmborer (Talk | contribs)
(Created page with 'I you don't want to open a new TopComponent to display or edit some data that is supported by NB platform, you can get the EditorKit for the mime type and reuse it in your own JE…')
Newer edit →

Revision as of 09:08, 27 September 2013

I you don't want to open a new TopComponent to display or edit some data that is supported by NB platform, 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