Note: These pages are being reviewed.
How to get mime type from
|The API described here is not official! Check the javadoc for its stability level.|
// Suppose you have javax.swing.text.Document String mimeType = NbEditorUtilities.getMimeType(document); // Suppose you have javax.swing.text.JTextComponent String mimeType = NbEditorUtilities.getMimeType(component);
The method accepting
JTextComponent is generally more practical, because
JTextComponent or its subclasses is what you usually have to start with.
Internally the method calls the
Document version of itself on the document
loaded in the component and returns its mime type (if it has any assigned). If
the document does not have mime type information attached (and non-Netbeans documents
generally don’t) the method will use the component’s
EditorKit to get it.
Applies to: NetBeans 6.x, the algorithm in
works fine in 5.0 and 5.5, but the method is not public.
See also: Editor Module API
Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqEditorHowToGetMimeTypeFromDocumentOrJTextComponent , that was last modified by NetBeans user Vstejskal on 2010-06-16T14:07:23Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.