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


Java DefaultEditorKit类代码示例

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


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

示例1: AbstractSearchResultsPanel

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
/**
 * Creates new form AbstractSearchResultsPanel
 */
public AbstractSearchResultsPanel(SearchComposition<?> searchComposition,
        SearchProvider.Presenter searchProviderPresenter) {
    this.searchComposition = searchComposition;
    this.searchProviderPresenter = searchProviderPresenter;
    initComponents();
    explorerManager = new ExplorerManager();

    ActionMap map = this.getActionMap();
    // map delete key to delete action
    map.put("delete", //NOI18N
            ExplorerUtils.actionDelete(explorerManager, false));
    map.put(DefaultEditorKit.copyAction,
            ExplorerUtils.actionCopy(explorerManager));
    map.put(DefaultEditorKit.cutAction,
            ExplorerUtils.actionCut(explorerManager));

    lookup = ExplorerUtils.createLookup(explorerManager,
            ResultView.getInstance().getActionMap());
    initActions();
    initToolbar();
    initSelectionListeners();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:AbstractSearchResultsPanel.java

示例2: ServicesTab

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
private ServicesTab() {
    manager = new ExplorerManager();
    manager.setRootContext(new ServicesNode());
    ActionMap map = getActionMap();
    map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(manager));
    map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(manager));
    map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(manager));
    map.put("delete", ExplorerUtils.actionDelete(manager, false));
    associateLookup(ExplorerUtils.createLookup(manager, map));
    view = new BeanTreeView();
    view.setRootVisible(false);
    setLayout(new BorderLayout());
    add(view);
    setName(ID);
    setDisplayName(NbBundle.getMessage(ServicesTab.class, "LBL_Services"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ServicesTab.java

示例3: addRound

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
public static RandomTestContainer.Round addRound(RandomTestContainer container) throws Exception {
    RandomTestContainer.Round round = container.addRound();
    round.setOpCount(100);
    round.setRatio(DocumentTesting.INSERT_CHAR, 5);
    round.setRatio(DocumentTesting.INSERT_TEXT, 3);
    round.setRatio(DocumentTesting.INSERT_PHRASE, 3);
    round.setRatio(DocumentTesting.REMOVE_CHAR, 3);
    round.setRatio(DocumentTesting.REMOVE_TEXT, 1);
    round.setRatio(DocumentTesting.UNDO, 1);
    round.setRatio(DocumentTesting.REDO, 1);

    round.setRatio(EditorPaneTesting.TYPE_CHAR, 10);
    EditorPaneTesting.setActionRatio(round, DefaultEditorKit.insertBreakAction, 1);
    EditorPaneTesting.setActionRatio(round, DefaultEditorKit.insertTabAction, 1);
    EditorPaneTesting.setActionRatio(round, DefaultEditorKit.deleteNextCharAction, 1);
    EditorPaneTesting.setActionRatio(round, DefaultEditorKit.deletePrevCharAction, 1);

    round.setRatio(EditorPaneTesting.MOVE, 20);
    round.setRatio(EditorPaneTesting.SELECT, 20);
    round.setRatio(EditorPaneTesting.SET_CARET_OFFSET, 1);
    return round;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ViewHierarchyRandomTesting.java

示例4: testFixedScenarios

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
public static void testFixedScenarios(RandomTestContainer container) throws Exception {
        // Fixed scenario - last undo throwed exc.
        RandomTestContainer.Context gContext = container.context();
        JEditorPane pane = EditorPaneTesting.getEditorPane(container);
        // Insert initial text into doc
//        DocumentTesting.insert(container.context(), 0, "abc\ndef\n\nghi");
        DocumentTesting.insert(gContext, 0, "\n\n\n\n\n");
        DocumentTesting.remove(gContext, 0, DocumentTesting.getDocument(gContext).getLength());

        // Check for an error caused by delete a line-2-begining and insert at line-1-end and two undos
        DocumentTesting.insert(gContext, 0, "a\nb\n\n");
        EditorPaneTesting.setCaretOffset(gContext, 2);
        EditorPaneTesting.performAction(gContext, pane, DefaultEditorKit.deleteNextCharAction);
        EditorPaneTesting.moveOrSelect(gContext, SwingConstants.WEST, false); // Should go to end of first line
        EditorPaneTesting.typeChar(gContext, 'c');
        DocumentTesting.undo(gContext, 1);
        DocumentTesting.undo(gContext, 1); // This throwed ISE for plain text mime type
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ViewHierarchyRandomTesting.java

示例5: testGlobalChanges

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
public void testGlobalChanges() throws Exception {
    class MyAction extends AbstractAction {
        public int cntEnabled;
        public int cntPerformed;
        
        public boolean isEnabled() {
            cntEnabled++;
            return true;
        }
        
        public void actionPerformed(ActionEvent ev) {
            cntPerformed++;
        }
    }
    MyAction myAction = new MyAction();
    
    ActionMap tc = new ActionMap();
    tc.put(DefaultEditorKit.copyAction, myAction);
    CopyAction a = (CopyAction)CopyAction.get(CopyAction.class);
    
    ActionsInfraHid.setActionMap(tc);
    try {
        assertTrue("MyAction is enabled", a.isEnabled());
        assertEquals("isEnabled called once", 1, myAction.cntEnabled);
        a.setActionPerformer(null);
        assertEquals("An enabled is currentlly called again", 2, myAction.cntEnabled);
    } finally {
        ActionsInfraHid.setActionMap(null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:CallbackSystemActionTest.java

示例6: initActionMapInEDT

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
private boolean initActionMapInEDT() {
    // Init action map: cut,copy,delete,paste actions.
    javax.swing.ActionMap am = editor.getActionMap();

    //#43157 - editor actions need to be accessible from outside using the TopComponent.getLookup(ActionMap.class) call.
    // used in main menu enabling/disabling logic.
    javax.swing.ActionMap paneMap = pane.getActionMap();
    // o.o.windows.DelegateActionMap.setParent() leads to CloneableEditor.getEditorPane()
    provideUnfinishedPane = true;
    try {
        am.setParent(paneMap);
    } finally {
        provideUnfinishedPane = false;
    }

    //#41223 set the defaults befor the custom editor + kit get initialized, giving them opportunity to
    // override defaults..
    paneMap.put(DefaultEditorKit.cutAction, getAction(DefaultEditorKit.cutAction));
    paneMap.put(DefaultEditorKit.copyAction, getAction(DefaultEditorKit.copyAction));
    paneMap.put("delete", getAction(DefaultEditorKit.deleteNextCharAction)); // NOI18N
    paneMap.put(DefaultEditorKit.pasteAction, getAction(DefaultEditorKit.pasteAction));
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:CloneableEditorInitializer.java

示例7: build

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
/**
 * This method builds the popup menu.
 */
private void build(ActionMap actionMap) {
    
    popupPresenter = new JPopupMenu();
    
    cutAction = actionMap.get(DefaultEditorKit.cutAction);
    copyAction = actionMap.get(DefaultEditorKit.copyAction);
    pasteAction = actionMap.get(DefaultEditorKit.pasteAction);
    selectAllAction = actionMap.get(DefaultEditorKit.selectAllAction);
    
    popupPresenter.add(createMenuItem("CTL_MenuItem_Cut", KeyEvent.VK_X, cutAction));
    popupPresenter.add(createMenuItem("CTL_MenuItem_Copy", KeyEvent.VK_C, copyAction));
    popupPresenter.add(createMenuItem("CTL_MenuItem_Paste", KeyEvent.VK_V, pasteAction));
    popupPresenter.addSeparator();
    popupPresenter.add(createMenuItem("CTL_MenuItem_SelectAll", KeyEvent.VK_A, selectAllAction));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CommitPopupBuilder.java

示例8: TemplatesPanel

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
/** Creates new form TemplatesPanel */
public TemplatesPanel (String pathToSelect) {
    
    ActionMap map = getActionMap ();
    map.put (DefaultEditorKit.copyAction, ExplorerUtils.actionCopy (getExplorerManager ()));
    map.put (DefaultEditorKit.cutAction, ExplorerUtils.actionCut (getExplorerManager ()));
    map.put (DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste (getExplorerManager ()));
    map.put ("delete", ExplorerUtils.actionDelete (getExplorerManager (), true)); // NOI18N
    
    initComponents ();
    createTemplateView ();
    treePanel.add (view, BorderLayout.CENTER);
    
    associateLookup (ExplorerUtils.createLookup (getExplorerManager (), map));
    initialize (pathToSelect);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TemplatesPanel.java

示例9: LicensePanel

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
/** Creates new form LicensePanel */
public LicensePanel(URL url) {
    this.url = url;
    initComponents();
    initAccessibility();
    try {
        jEditorPane1.setPage(url);
    } catch (IOException exc) {
        //Problem with locating file
        System.err.println("Exception: " + exc.getMessage()); //NOI18N
        exc.printStackTrace();
    }
    ActionMap actionMap = jEditorPane1.getActionMap();
    actionMap.put(DefaultEditorKit.upAction, new ScrollAction(-1));
    actionMap.put(DefaultEditorKit.downAction, new ScrollAction(1));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:LicensePanel.java

示例10: CatalogPanel

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
/** Creates new form CatalogPanel */
public CatalogPanel() {
    
    ActionMap map = getActionMap();
    map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(getExplorerManager()));
    map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(getExplorerManager()));
    map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(getExplorerManager()));
    map.put("delete", ExplorerUtils.actionDelete(getExplorerManager(), true)); // NOI18N
    
    initComponents();
    createCatalogView();
    treePanel.add(view, BorderLayout.CENTER);
    
    associateLookup(ExplorerUtils.createLookup(getExplorerManager(), map));
    initialize();
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CatalogPanel.java

示例11: ListViewNavigatorPanel

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
public ListViewNavigatorPanel () {
    manager = new ExplorerManager();
    ActionMap map = getActionMap();
    copyAction = ExplorerUtils.actionCopy(manager);
    map.put(DefaultEditorKit.copyAction, copyAction);
    map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(manager));
    map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(manager));
    map.put("delete", ExplorerUtils.actionDelete(manager, true)); // or false

    lookup = ExplorerUtils.createLookup(manager, map);

    listView = new ListView();
    fillListView(listView);
            
    add(listView);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ListViewNavigatorPanel.java

示例12: testNewlineLineOne

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
public void testNewlineLineOne() throws Exception {
    loggingOn();
    RandomTestContainer container = createContainer();
    JEditorPane pane = container.getInstance(JEditorPane.class);
    Document doc = pane.getDocument();
    doc.putProperty("mimeType", "text/plain");
    ViewHierarchyRandomTesting.initRandomText(container);
    ViewHierarchyRandomTesting.addRound(container).setOpCount(OP_COUNT);
    ViewHierarchyRandomTesting.testFixedScenarios(container);

    RandomTestContainer.Context context = container.context();
    // Clear document contents
    DocumentTesting.remove(context, 0, doc.getLength());
    DocumentTesting.insert(context, 0, "\n");
    EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, false);
    EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, true);
    EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deleteNextCharAction);
    DocumentTesting.undo(context, 1);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:JavaViewHierarchyRandomTest.java

示例13: testDeleteAterInsertBreak

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
public void testDeleteAterInsertBreak() throws Exception {
        loggingOn();
        RandomTestContainer container = createContainer();
        JEditorPane pane = container.getInstance(JEditorPane.class);
        Document doc = pane.getDocument();
        doc.putProperty("mimeType", "text/plain");
        ViewHierarchyRandomTesting.initRandomText(container);
        RandomTestContainer.Context context = container.context();
        DocumentTesting.insert(context, 0,
" osen   \n\n\n  esl\t\ta \t\t \n\n\nabcd\td  m\t\tabcdef\te\t\tab\tcdef\tef\tkojd \t\t \n\n\n        t\t vpjm\ta\ngooywzmj           q\tugos\tdefy\t   i  xs    us tg z"
        );

        EditorPaneTesting.setCaretOffset(context, 70);
        DocumentTesting.remove(context, 50, 10);
        EditorPaneTesting.performAction(context, pane, DefaultEditorKit.insertBreakAction);
        EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deleteNextCharAction);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JavaViewHierarchyRandomTest.java

示例14: testTwoDeletes

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
public void testTwoDeletes() throws Exception {
        loggingOn();
        RandomTestContainer container = createContainer();
        JEditorPane pane = container.getInstance(JEditorPane.class);
        Document doc = pane.getDocument();
        doc.putProperty("mimeType", "text/plain");
        ViewHierarchyRandomTesting.initRandomText(container);
        RandomTestContainer.Context context = container.context();
        DocumentTesting.insert(context, 0,
" osen   \n\n\nbs\tmn\nziil  esl\t\ta \t\t \n\n\nabc \n\n\nd\td  m\t\ta\nbcdef\te\t\tab\tcdef\tef\tkojd \t\t \n\n\net\t vpjm\ta\ngooywzmj           q\tugos\tdefy\t   i xs    us ttl\tg z"
        );

        EditorPaneTesting.setCaretOffset(context, 115);
        EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deletePrevCharAction);
        EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deleteNextCharAction);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:JavaViewHierarchyRandomTest.java

示例15: testSelectionAndInsertTab

import javax.swing.text.DefaultEditorKit; //导入依赖的package包/类
public void testSelectionAndInsertTab() throws Exception {
        loggingOn();
        RandomTestContainer container = createContainer();
        JEditorPane pane = container.getInstance(JEditorPane.class);
        Document doc = pane.getDocument();
        doc.putProperty("mimeType", "text/plain");
        ViewHierarchyRandomTesting.initRandomText(container);
        RandomTestContainer.Context context = container.context();
        DocumentTesting.insert(context, 0,
" osen   \n\n\n  esl\t\ta \t\t \n\n\nabcd\td  m\t\tabcdef\te\t\tab\tcdef\tef\tkojd p\t\t \n\n\n        t\t vpjm\ta\ngooywzmj           q\tugos\tdefy\t   i  xs    us tg z"
        );
        EditorPaneTesting.setCaretOffset(context, 64);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, false);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.SOUTH, true);
        DocumentTesting.insert(context, 19, "g");
        EditorPaneTesting.moveOrSelect(context, SwingConstants.EAST, true);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.NORTH, true);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.WEST, true);
        EditorPaneTesting.performAction(context, pane, DefaultEditorKit.deletePrevCharAction);
        EditorPaneTesting.performAction(context, pane, DefaultEditorKit.insertTabAction);
        EditorPaneTesting.moveOrSelect(context, SwingConstants.EAST, false);
        EditorPaneTesting.typeChar(context, 'f');
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:JavaViewHierarchyRandomTest.java


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