當前位置: 首頁>>代碼示例>>Java>>正文


Java JEditorPane.getEditorKit方法代碼示例

本文整理匯總了Java中javax.swing.JEditorPane.getEditorKit方法的典型用法代碼示例。如果您正苦於以下問題:Java JEditorPane.getEditorKit方法的具體用法?Java JEditorPane.getEditorKit怎麽用?Java JEditorPane.getEditorKit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JEditorPane的用法示例。


在下文中一共展示了JEditorPane.getEditorKit方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testPlainEditorKits

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void testPlainEditorKits() {
    // VIS: JEditorPane when constructed contains javax.swing.JEditorPane$PlainEditorKit
    // and calling JEP.setContenetType("text/plain") has no effect. IMO this is probably
    // a defect in JDK, becuase JEP should always honour its EditorKit registry.
    JEditorPane pane = new JEditorPane();
    pane.setEditorKit(new DefaultEditorKit() {
        public @Override String getContentType() {
            return "text/whatever";
        }
    });
    setContentTypeInAwt(pane, "text/plain");
    
    // Test JDK kit
    EditorKit kitFromJdk = pane.getEditorKit();
    assertNotNull("Can't find JDK kit for text/plain", kitFromJdk);
    assertEquals("The kit for text/plain should not be from JDK", 
        "org.netbeans.modules.editor.plain.PlainKit", kitFromJdk.getClass().getName());

    // Test Netbeans kit
    EditorKit kitFromNb = CloneableEditorSupport.getEditorKit("text/plain");
    assertNotNull("Can't find Nb kit for text/plain", kitFromNb);
    assertEquals("Wrong Nb kit for text/plain", 
        "org.netbeans.modules.editor.plain.PlainKit", kitFromNb.getClass().getName());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:EditorSanityTest.java

示例2: getToolTip

import javax.swing.JEditorPane; //導入方法依賴的package包/類
@Override
public JComponent getToolTip(double x, double y, Shape allocation) {
    Container container = getContainer();
    if (container instanceof JEditorPane) {
        JEditorPane editorPane = (JEditorPane) getContainer();
        JEditorPane tooltipPane = new JEditorPane();
        EditorKit kit = editorPane.getEditorKit();
        Document doc = getDocument();
        if (kit != null && doc != null) {
            Element lineRootElement = doc.getDefaultRootElement();
            tooltipPane.putClientProperty(FoldViewFactory.DISPLAY_ALL_FOLDS_EXPANDED_PROPERTY, true);
            try {
                // Start-offset of the fold => line start => position
                int lineIndex = lineRootElement.getElementIndex(fold.getStartOffset());
                Position pos = doc.createPosition(
                        lineRootElement.getElement(lineIndex).getStartOffset());
                // DocumentView.START_POSITION_PROPERTY
                tooltipPane.putClientProperty("document-view-start-position", pos); // NOI18N
                // End-offset of the fold => line end => position
                lineIndex = lineRootElement.getElementIndex(fold.getEndOffset());
                pos = doc.createPosition(lineRootElement.getElement(lineIndex).getEndOffset());
                // DocumentView.END_POSITION_PROPERTY
                tooltipPane.putClientProperty("document-view-end-position", pos); // NOI18N
                tooltipPane.putClientProperty("document-view-accurate-span", true); // NOI18N
                // Set the same kit and document
                tooltipPane.setEditorKit(kit);
                tooltipPane.setDocument(doc);
                tooltipPane.setEditable(false);
                return new FoldToolTip(editorPane, tooltipPane, getBorderColor());
            } catch (BadLocationException e) {
                // => return null
            }
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:FoldView.java

示例3: createEditor

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public Component createEditor(JEditorPane j) {
    EditorUI editorUI = Utilities.getEditorUI(j);
    if (editorUI == null) { // Editor kit not installed yet??
        javax.swing.plaf.TextUI ui = j.getUI();
        javax.swing.text.EditorKit kit = j.getEditorKit();
        throw new IllegalStateException("NbEditorDocument.createEditor(): ui=" + ui + // NOI18N
                ", kit=" + kit + ", pane=" + j); // NOI18N
    }
    return editorUI.getExtComponent();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:NbEditorDocument.java

示例4: testHTMLEditorKits

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void testHTMLEditorKits() {
    JEditorPane pane = new JEditorPane();
    setContentTypeInAwt(pane, "text/html");
    
    // Test JDK kit
    EditorKit kitFromJdk = pane.getEditorKit();
    assertNotNull("Can't find JDK kit for text/html", kitFromJdk);
    assertTrue("Wrong JDK kit for text/html", kitFromJdk instanceof HTMLEditorKit);

    // Check that org.netbeans.modules.html.editor is available
    boolean htmlPresent = false;
    Collection<? extends ModuleInfo> modules = Lookup.getDefault().lookupAll(ModuleInfo.class);
    for(ModuleInfo info : modules) {
        if (info.getCodeNameBase().equals("org.netbeans.modules.html.editor")) {
            htmlPresent = true;
            break;
        }
    }

    if (htmlPresent) {
        // Test Netbeans kit
        EditorKit kitFromNb = CloneableEditorSupport.getEditorKit("text/html");
        assertNotNull("Can't find Nb kit for text/html", kitFromNb);
        assertEquals("Wrong Nb kit for text/html",
            "org.netbeans.modules.html.editor.api.HtmlKit", kitFromNb.getClass().getName());
    } else {
        log("Module org.netbeans.modules.html.editor not present, skipping HTMLKit test...");
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:EditorSanityTest.java

示例5: testTextRtfEditorKits

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void testTextRtfEditorKits() {
    JEditorPane pane = new JEditorPane();
    setContentTypeInAwt(pane, "text/rtf");
    
    // Test JDK kit
    EditorKit kitFromJdk = pane.getEditorKit();
    assertNotNull("Can't find JDK kit for text/rtf", kitFromJdk);
    assertTrue("Wrong JDK kit for application/rtf", kitFromJdk instanceof RTFEditorKit);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:EditorSanityTest.java

示例6: testApplicationRtfEditorKits

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void testApplicationRtfEditorKits() {
    JEditorPane pane = new JEditorPane();
    setContentTypeInAwt(pane, "application/rtf");
    
    // Test JDK kit
    EditorKit kitFromJdk = pane.getEditorKit();
    assertNotNull("Can't find JDK kit for application/rtf", kitFromJdk);
    assertTrue("Wrong JDK kit for application/rtf", kitFromJdk instanceof RTFEditorKit);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:EditorSanityTest.java

示例7: getStyledEditorKit

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
 * Gets the editor kit associated with an editor pane.
 *
 * @param e the editor pane
 * @return the kit
 * @exception IllegalArgumentException for the wrong document type
 */
protected final StyledEditorKit getStyledEditorKit(JEditorPane e) {
    EditorKit k = e.getEditorKit();
    if (k instanceof StyledEditorKit) {
        return (StyledEditorKit) k;
    }
    throw new IllegalArgumentException("EditorKit must be StyledEditorKit");
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:StyledEditorKit.java

示例8: getEditorKit

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/** Fetches the EditorKit for the UI.
*
* @return the component capabilities
*/
public @Override EditorKit getEditorKit(JTextComponent c) {
    JEditorPane pane = (JEditorPane)getComponent();
    return (pane == null) ? null : pane.getEditorKit();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:BaseTextUI.java

示例9: runKitAction

import javax.swing.JEditorPane; //導入方法依賴的package包/類
protected void runKitAction(JEditorPane jt, String actionName, String cmd) {
    BaseKit kit = (BaseKit)jt.getEditorKit();
    Action a = kit.getActionByName(actionName);
    assertNotNull(a);
    a.actionPerformed(new ActionEvent(jt, 0, cmd));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:CslTestBase.java


注:本文中的javax.swing.JEditorPane.getEditorKit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。