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