javax.swing.JEditorPane#getEditorKit ( )源码实例Demo

下面列出了javax.swing.JEditorPane#getEditorKit ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: EditorSanityTest.java
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());
}
 
源代码2 项目: jdk1.8-source-analysis   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码3 项目: jpexs-decompiler   文件: ActionUtils.java
/**
 * Return the DefaultSyntaxKit of this target, or null if the target does not
 * have a DefaultSyntaxKit
 * @param target
 * @return kit or null
 */
public static DefaultSyntaxKit getSyntaxKit(JTextComponent target) {
	DefaultSyntaxKit kit = null;
	if (target instanceof JEditorPane) {
		JEditorPane jEditorPane = (JEditorPane) target;
		EditorKit k = jEditorPane.getEditorKit();
		if (k instanceof DefaultSyntaxKit) {
			 kit = (DefaultSyntaxKit) k;
		}
	}
	return kit;
}
 
源代码4 项目: TencentKona-8   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码5 项目: openjdk-8-source   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码6 项目: JDKSourceCode1.8   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码7 项目: openjdk-jdk8u   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码8 项目: netbeans   文件: FoldView.java
@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;
}
 
源代码9 项目: netbeans   文件: NbEditorDocument.java
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();
}
 
源代码10 项目: jdk8u-jdk   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码11 项目: netbeans   文件: EditorSanityTest.java
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);
}
 
源代码12 项目: netbeans   文件: EditorSanityTest.java
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);
}
 
源代码13 项目: openjdk-8   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码14 项目: Bytecoder   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码15 项目: openjdk-jdk9   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码16 项目: jpexs-decompiler   文件: ToggleComponentAction.java
@Override
public void actionPerformed(ActionEvent e) {
    JTextComponent target = getTextComponent(e);
    if (target instanceof JEditorPane) {
        JEditorPane jEditorPane = (JEditorPane) target;
        DefaultSyntaxKit kit = (DefaultSyntaxKit) jEditorPane.getEditorKit();
        boolean status = kit.toggleComponent(jEditorPane, componentName);
        putValue(SELECTED_KEY, status);
    }
}
 
源代码17 项目: Java8CN   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码18 项目: jdk8u-dev-jdk   文件: StyledEditorKit.java
/**
 * 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");
}
 
源代码19 项目: netbeans   文件: BaseTextUI.java
/** 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();
}
 
源代码20 项目: netbeans   文件: CslTestBase.java
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));
}