blob: 180a44ee75b57990a48ea5292eaca23d41dbeffc [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= DevFaqEditorHowToReuseEditorHighlighting
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqEditorHowToReuseEditorHighlighting
:description: Apache NetBeans wiki DevFaqEditorHowToReuseEditorHighlighting
:toc: left
:toc-title:
:syntax: true
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:
[source,java]
----
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.
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevFaqEditorHowToReuseEditorHighlighting[http://wiki.netbeans.org/DevFaqEditorHowToReuseEditorHighlighting] ,
that was last modified by NetBeans user Jmborer
on 2013-09-27T09:13:03Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.