当前位置: 首页>>代码示例>>Java>>正文


Java EditorKit.createDefaultDocument方法代码示例

本文整理汇总了Java中javax.swing.text.EditorKit.createDefaultDocument方法的典型用法代码示例。如果您正苦于以下问题:Java EditorKit.createDefaultDocument方法的具体用法?Java EditorKit.createDefaultDocument怎么用?Java EditorKit.createDefaultDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.EditorKit的用法示例。


在下文中一共展示了EditorKit.createDefaultDocument方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWriterFromKit

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
/** @return The writer or <code>null</code>. */
private Writer getWriterFromKit(File file, FileObject fo, FileLock lock, String mimeType) throws FileNotFoundException {
    EditorKit kit = CloneableEditorSupport.getEditorKit(mimeType);
    if (kit.getContentType().equalsIgnoreCase("text/plain") && "text/x-dtd".equalsIgnoreCase(mimeType)) {
         // Use XML kit for DTDs if not defined otherwise
        kit = CloneableEditorSupport.getEditorKit("text/xml");
    }
    //System.out.println("  KIT for "+mimeType+" = "+kit);
    if (kit != null) {
        Document doc = kit.createDefaultDocument();
        return new DocWriter(doc, fo, lock, file, kit, null, null);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:EncodedReaderFactory.java

示例2: createDocument

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
private StyledDocument createDocument(EditorKit kit) {
    Document doc = kit.createDefaultDocument();
    if (doc instanceof StyledDocument) {
        return (StyledDocument)doc;
    } else {
        return new org.openide.text.FilterDocument(doc);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:IndentFileEntry.java

示例3: initializeModel

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
private Document initializeModel(EditorKit kit, URL page) {
    Document doc = kit.createDefaultDocument();

    if (doc.getProperty(Document.StreamDescriptionProperty) == null) {
        doc.putProperty(Document.StreamDescriptionProperty, page);
    }
    return doc;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:9,代码来源:Navigator.java

示例4: getSourceForMimeType

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
private Source getSourceForMimeType(String mimeType) {
    EditorKit kit = new DefaultEditorKit();
    Document doc = kit.createDefaultDocument();
    doc.putProperty("mimeType", mimeType);
    return Source.create(doc);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:WebUtilsTest.java

示例5: getReaderFromKit

import javax.swing.text.EditorKit; //导入方法依赖的package包/类
/** @return The reader or <code>null</code>. */
private Reader getReaderFromKit(File file, FileObject fo, String mimeType) throws FileNotFoundException {
    EditorKit kit = CloneableEditorSupport.getEditorKit(mimeType);
    if (kit.getContentType().equalsIgnoreCase("text/plain") && "text/x-dtd".equalsIgnoreCase(mimeType)) {
         // Use XML kit for DTDs if not defined otherwise
        kit = CloneableEditorSupport.getEditorKit("text/xml");
    }
    //System.out.println("  KIT for "+mimeType+" = "+kit);
    if (kit != null) {
        Document doc = kit.createDefaultDocument();
        InputStream stream = null;
        try {
            if (file != null) {
                stream = new FileInputStream(file);
            } else {
                stream = fo.getInputStream();
            }
            kit.read(stream, doc, 0);
            String text = doc.getText(0, doc.getLength());
            //System.out.println("  TEXT = "+text);
            doc = null; // Release it, we have the text
            return new StringReader(text);
        } catch (IOException ioex) {
            FileNotFoundException fnfex;
            if (file != null) {
                fnfex = new FileNotFoundException("Can not read file "+file.getAbsolutePath());
            } else {
                fnfex = new FileNotFoundException("Can not read file "+fo);
            }
            fnfex.initCause(ioex);
            throw fnfex;
        } catch (BadLocationException blex) { // Something wrong???
            ErrorManager.getDefault().notify(blex);
        } finally {
            if (stream != null) {
                try { stream.close(); } catch (IOException e) {}
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:EncodedReaderFactory.java


注:本文中的javax.swing.text.EditorKit.createDefaultDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。