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


Java EditorKit类代码示例

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


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

示例1: CustomizeScriptPanel

import javax.swing.text.EditorKit; //导入依赖的package包/类
/** Create the wizard panel component and set up some basic properties. */
public CustomizeScriptPanel (CustomizeScriptWizardPanel wiz) {
    initComponents ();
    initAccessibility ();
    // Provide a name in the title bar.
    setName (NbBundle.getMessage (CustomizeScriptPanel.class, "CSP_LBL_cust_gend_ant_script"));
    scriptPane.setContentType ("text/xml"); // NOI18N
    // Hack; EditorKit does not permit "fallback" kits, so we have to
    // mimic what the IDE itself does:
    EditorKit kit = scriptPane.getEditorKit ();
    String clazz = kit.getClass ().getName ();
    if (clazz.equals ("javax.swing.text.DefaultEditorKit") || // NOI18N
           clazz.equals ("javax.swing.JEditorPane$PlainEditorKit")) { // NOI18N
        scriptPane.setEditorKit (JEditorPane.createEditorKitForContentType ("text/plain")); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CustomizeScriptPanel.java

示例2: AdvancedActionPanel

import javax.swing.text.EditorKit; //导入依赖的package包/类
public AdvancedActionPanel(AntProjectCookie project, Set<TargetLister.Target> allTargets) {
    this.project = project;
    this.allTargets = allTargets;
    initComponents();
    
    getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(AdvancedActionPanel.class,"AdvancedActionsPanel.acsd.title"));
    
    Mnemonics.setLocalizedText(targetLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.targetLabel.text"));
    Mnemonics.setLocalizedText(targetDescriptionLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.targetDescriptionLabel.text"));
    Mnemonics.setLocalizedText(propertiesLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.propertiesLabel.text"));
    Mnemonics.setLocalizedText(verbosityLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.verbosityLabel.text"));
    // Hack; EditorKit does not permit "fallback" kits, so we have to
    // mimic what the IDE itself does:
    EditorKit kit = propertiesPane.getEditorKit();
    String clazz = kit.getClass().getName();
    if (clazz.equals("javax.swing.text.DefaultEditorKit") || // NOI18N
            clazz.equals("javax.swing.JEditorPane$PlainEditorKit")) { // NOI18N
        propertiesPane.setEditorKit(JEditorPane.createEditorKitForContentType("text/plain")); // NOI18N
    }
    // Make ENTER run OK, not change the combo box.
    targetComboBox.getInputMap().remove(KeyStroke.getKeyStroke("ENTER")); // NOI18N
    initializeFields();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:AdvancedActionPanel.java

示例3: getFreeSyntax

import javax.swing.text.EditorKit; //导入依赖的package包/类
Syntax getFreeSyntax() {
        EditorKit kit = getEditorKit();
        if (kit instanceof BaseKit) {
            return ((BaseKit) kit).createSyntax(this);
        } else {
            return new BaseKit.DefaultSyntax();
        }
//        synchronized (syntaxList) {
//            int cnt = syntaxList.size();
//            if (cnt > 0) {
//                return syntaxList.remove(cnt - 1);
//            } else {
//                EditorKit kit = getEditorKit();
//                if (kit instanceof BaseKit) {
//                    return ((BaseKit) kit).createSyntax(this);
//                } else {
//                    return new BaseKit.DefaultSyntax();
//                }
//            }
//        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:BaseDocument.java

示例4: print

import javax.swing.text.EditorKit; //导入依赖的package包/类
/**
 * Print into given container.
 *
 * @param container printing container into which the printing will be done.
 * @param usePrintColoringMap use printing coloring settings instead
 *  of the regular ones.
 * @param lineNumberEnabled if set to false the line numbers will not be printed.
 *  If set to true the visibility of line numbers depends on the settings
 *  for the line number visibility.
 * @param startOffset start offset of text to print
 * @param endOffset end offset of text to print
 */
public void print(PrintContainer container, boolean usePrintColoringMap, boolean lineNumberEnabled, int startOffset,
                  int endOffset) {
    readLock();
    try {
        EditorUI editorUI;
        EditorKit kit = getEditorKit();
        if (kit instanceof BaseKit) {
            editorUI = ((BaseKit) kit).createPrintEditorUI(this, usePrintColoringMap, lineNumberEnabled);
        } else {
            editorUI = new EditorUI(this, usePrintColoringMap, lineNumberEnabled);
        }

        DrawGraphics.PrintDG printDG = new DrawGraphics.PrintDG(container);
        DrawEngine.getDrawEngine().draw(printDG, editorUI, startOffset, endOffset, 0, 0, Integer.MAX_VALUE);
    } catch (BadLocationException e) {
        LOG.log(Level.WARNING, null, e);
    } finally {
        readUnlock();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:BaseDocument.java

示例5: loadFromStreamToKit

import javax.swing.text.EditorKit; //导入依赖的package包/类
@Override
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit) throws IOException, BadLocationException {
    if (guardedEditor == null) {
        guardedEditor = new FormGEditor();
        GuardedSectionsFactory gFactory = GuardedSectionsFactory.find("text/x-java");
        if (gFactory != null) {
            guardedProvider = gFactory.create(guardedEditor);
        }
    }

    if (guardedProvider != null) {
        guardedEditor.doc = doc;
        Charset c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
        Reader reader = guardedProvider.createGuardedReader(stream, c);
        try {
            kit.read(reader, doc, 0);
        } finally {
            reader.close();
        }
    } else {
        super.loadFromStreamToKit(doc, stream, kit);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:GuardedBlockTest.java

示例6: getSearchableKit

import javax.swing.text.EditorKit; //导入依赖的package包/类
/**
 * Get searchable editor kit for the given kit.
 * @param kit non-null kit.
 * @return non-null searchable kit.
 */
public static SearchableEditorKit getSearchableKit(EditorKit kit) {
    SearchableEditorKit searchableKit;
    if (kit instanceof SearchableEditorKit) {
        searchableKit = ((SearchableEditorKit)kit);
    } else {
        synchronized (kit2searchable) {
            searchableKit = kit2searchable.get(kit);
            if (searchableKit == null) {
                searchableKit = new DefaultSearchableKit(kit);
                registerSearchableKit(kit, searchableKit);
            }
        }
    }
    return searchableKit;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:EditorActionUtilities.java

示例7: actionPerformed

import javax.swing.text.EditorKit; //导入依赖的package包/类
public void actionPerformed(ActionEvent evt) {
    // Find the right action for the corresponding editor kit
    JTextComponent component = getTextComponent(evt);
    if (component != null) {
        TextUI ui = component.getUI();
        if (ui != null) {
            EditorKit kit = ui.getEditorKit(component);
            if (kit != null) {
                Action action = EditorUtilities.getAction(kit, actionName);
                if (action != null) {
                    action.actionPerformed(evt);
                } else {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Action '" + actionName + "' not found in editor kit " + kit + '\n'); // NOI18N
                    }
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:PresenterEditorAction.java

示例8: createContainer

import javax.swing.text.EditorKit; //导入依赖的package包/类
public static RandomTestContainer createContainer(EditorKit kit) throws Exception {
    // Ensure the new view hierarchy is turned on
    System.setProperty("org.netbeans.editor.linewrap", "true");
    // Set the property for synchronous highlights firing since otherwise
    // the repeatability of problems with view hierarchy is none or limited.
    System.setProperty("org.netbeans.editor.sync.highlights", "true");
    System.setProperty("org.netbeans.editor.linewrap.edt", "true");

    RandomTestContainer container = new RandomTestContainer();
    EditorPaneTesting.initContainer(container, kit);
    DocumentTesting.initContainer(container);
    DocumentTesting.initUndoManager(container);
    container.addCheck(new ViewHierarchyCheck());
    JEditorPane pane = EditorPaneTesting.getEditorPane(container);
    pane.putClientProperty("text-line-wrap", "words"); // SimpleValueNames.TEXT_LINE_WRAP
    return container;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ViewHierarchyRandomTesting.java

示例9: loadFromStreamToKit

import javax.swing.text.EditorKit; //导入依赖的package包/类
@Override
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit)
throws IOException, BadLocationException {
    Exception e = new Exception();
    StringWriter sw = new StringWriter(500);
    PrintWriter pw = new PrintWriter(sw);
    pw.println("loadFromStreamToKit"
    + " this:[" + Integer.toHexString(System.identityHashCode(doc)) + "]"
    + " thread:" + Thread.currentThread().getName());
    e.printStackTrace(pw);
    pw.flush();

    inits.add(new Exception(sw.toString()));
    
    super.loadFromStreamToKit(doc, stream, kit);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CloneableEditorDoubleLoadingTest.java

示例10: createSyntax

import javax.swing.text.EditorKit; //导入依赖的package包/类
@Override
public org.netbeans.editor.Syntax createSyntax(EditorKit host, Document doc, String mimeType) {
    if (DTDKit.MIME_TYPE.equals(mimeType)) {
        return new JJEditorSyntax( 
            new DTDSyntaxTokenManager(null).new Bridge(),
            new DTDSyntaxTokenMapper(),
            DTDTokenContext.contextPath
        );

    } else if (XMLKit.MIME_TYPE.equals(mimeType)) {
        return new XMLDefaultSyntax();
    } else if (ENTKit.MIME_TYPE.equals(mimeType)) {
        return new XMLDefaultSyntax();
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:XMLSyntaxBridgeImpl.java

示例11: findEditorKeys

import javax.swing.text.EditorKit; //导入依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                 Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DocumentationScrollPane.java

示例12: createStyledDocument

import javax.swing.text.EditorKit; //导入依赖的package包/类
/** Let's the super method create the document and also annotates it
* with Title and StreamDescription properties.
*
* @param kit kit to user to create the document
* @return the document annotated by the properties
*/
@Override
protected StyledDocument createStyledDocument (EditorKit kit) {
    StyledDocument doc = super.createStyledDocument (kit);
        
    // set document name property
    doc.putProperty(Document.TitleProperty,
        FileUtil.getFileDisplayName(obj.getPrimaryFile())
    );
    // set dataobject to stream desc property
    doc.putProperty(Document.StreamDescriptionProperty,
        obj
    );
    
    //Report the document into the Timers&Counters window:
    Logger.getLogger("TIMER").log(Level.FINE, "Document", new Object[] {obj.getPrimaryFile(), doc});
    
    return doc;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:DataEditorSupport.java

示例13: AdvancedActionPanel

import javax.swing.text.EditorKit; //导入依赖的package包/类
public AdvancedActionPanel(AntProjectCookie project, Set/*<TargetLister.Target>*/ allTargets) {
    this.project = project;
    this.allTargets = allTargets;
    initComponents();
    Mnemonics.setLocalizedText(targetLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.targetLabel.text"));
    Mnemonics.setLocalizedText(targetDescriptionLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.targetDescriptionLabel.text"));
    Mnemonics.setLocalizedText(propertiesLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.propertiesLabel.text"));
    Mnemonics.setLocalizedText(verbosityLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.verbosityLabel.text"));
    // Hack; EditorKit does not permit "fallback" kits, so we have to
    // mimic what the IDE itself does:
    EditorKit kit = propertiesPane.getEditorKit();
    String clazz = kit.getClass().getName();
    if (clazz.equals("javax.swing.text.DefaultEditorKit") || // NOI18N
            clazz.equals("javax.swing.JEditorPane$PlainEditorKit")) { // NOI18N
        propertiesPane.setEditorKit(JEditorPane.createEditorKitForContentType("text/plain")); // NOI18N
    }
    // Make ENTER run OK, not change the combo box.
    targetComboBox.getInputMap().remove(KeyStroke.getKeyStroke("ENTER")); // NOI18N
    initializeFields();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AdvancedActionPanel.java

示例14: Typing

import javax.swing.text.EditorKit; //导入依赖的package包/类
public Typing(final EditorKit kit, final String textWithPipe) {
    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                pane = new JEditorPane();
                pane.setEditorKit(kit);
                Document doc = pane.getDocument();
                // Required by Java's default key typed
                doc.putProperty(Language.class, HTMLTokenId.language());
                doc.putProperty("mimeType", "text/html");
                int caretOffset = textWithPipe.indexOf('|');
                String text;
                if (caretOffset != -1) {
                    text = textWithPipe.substring(0, caretOffset) + textWithPipe.substring(caretOffset + 1);
                } else {
                    text = textWithPipe;
                }
                pane.setText(text);
                pane.setCaretPosition((caretOffset != -1) ? caretOffset : doc.getLength());
            }
        });
    } catch (InterruptedException | InvocationTargetException e) {
        throw new RuntimeException(e.getCause());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:Typing.java

示例15: Context

import javax.swing.text.EditorKit; //导入依赖的package包/类
public Context(final EditorKit kit, final String textWithPipe) {
    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                pane = new JEditorPane();
                pane.setEditorKit(kit);
                Document doc = pane.getDocument();
                // Required by Java's default key typed
                doc.putProperty(Language.class, JavaTokenId.language());
                doc.putProperty("mimeType", "text/x-java");
                int caretOffset = textWithPipe.indexOf('|');
                String text;
                if (caretOffset != -1) {
                    text = textWithPipe.substring(0, caretOffset) + textWithPipe.substring(caretOffset + 1);
                } else {
                    text = textWithPipe;
                }
                pane.setText(text);
                pane.setCaretPosition((caretOffset != -1) ? caretOffset : doc.getLength());
            }
        });
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:TypingCompletionUnitTest.java


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