當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。