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


Java JTextComponent.getKeymap方法代码示例

本文整理汇总了Java中javax.swing.text.JTextComponent.getKeymap方法的典型用法代码示例。如果您正苦于以下问题:Java JTextComponent.getKeymap方法的具体用法?Java JTextComponent.getKeymap怎么用?Java JTextComponent.getKeymap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.JTextComponent的用法示例。


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

示例1: addAcceleretors

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private void addAcceleretors(Action a, JMenuItem item, JTextComponent target) {
    // Try to get the accelerator
    Keymap km = target.getKeymap();

    if (km != null) {
        KeyStroke[] keys = km.getKeyStrokesForAction(a);

        if ((keys != null) && (keys.length > 0)) {
            item.setAccelerator(keys[0]);
        } else if (a != null) {
            KeyStroke ks = (KeyStroke)a.getValue(Action.ACCELERATOR_KEY);

            if (ks != null) {
                item.setAccelerator(ks);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CslEditorKit.java

示例2: findEditorKeys

import javax.swing.text.JTextComponent; //导入方法依赖的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 && editorActionName != null) {
        Action a = component.getActionMap().get(editorActionName);
        Keymap km = component.getKeymap();
        if (a != null && km != null) {
            KeyStroke[] keys = km.getKeyStrokesForAction(a);
            if (keys != null && keys.length > 0) {
                ret = keys;
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CompletionScrollPane.java

示例3: findEditorKeys

import javax.swing.text.JTextComponent; //导入方法依赖的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

示例4: findEditorKeys

import javax.swing.text.JTextComponent; //导入方法依赖的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

示例5: addAcceleretors

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private void addAcceleretors(Action a, JMenuItem item, JTextComponent target){
    // Try to get the accelerator
    Keymap km = (target == null) ? BaseKit.getKit(BaseKit.class).getKeymap() :
            target.getKeymap();
    if (km != null) {
        KeyStroke[] keys = km.getKeyStrokesForAction(a);
        if (keys != null && keys.length > 0) {
            boolean added = false;
            for (int i = 0; i<keys.length; i++){
                if ((keys[i].getKeyCode() == KeyEvent.VK_MULTIPLY) ||
                    keys[i].getKeyCode() == KeyEvent.VK_ADD){
                    item.setMnemonic(keys[i].getKeyCode());
                    added = true;
                    break;
                }
            }
            if (added == false) item.setMnemonic(keys[0].getKeyCode());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:NbEditorKit.java

示例6: findEditorKeys

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(JTextComponent component, String editorActionName, KeyStroke defaultKey) {
    // 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) {
        Action a = component.getActionMap().get(editorActionName);
        Keymap km = component.getKeymap();
        if (a != null && km != null) {
            KeyStroke[] keys = km.getKeyStrokesForAction(a);
            if (keys != null && keys.length > 0) {
                ret = keys;
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ScrollCompletionPane.java

示例7: addAccelerators

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Adds accelerators to given JMenuItem taken from the action */
protected static void addAccelerators(Action a, JMenuItem item, JTextComponent target){
    if (target == null || a==null || item==null) return;
    
    // get accelerators from kitAction
    Action kitAction = getActionByName((String)a.getValue(Action.NAME));
    if (kitAction!=null) a = kitAction;
    // Try to get the accelerator, TopComponent action could be obsoleted
    Keymap km = target.getKeymap();

    if (km != null) {
        KeyStroke[] keys = km.getKeyStrokesForAction(a);
        KeyStroke itemAccelerator = item.getAccelerator();
        
        if (keys != null && keys.length > 0) {
            if (itemAccelerator==null || !itemAccelerator.equals(keys[0])){
                item.setAccelerator(keys[0]);
            }
        }else{
            if (itemAccelerator!=null && kitAction!=null){
                item.setAccelerator(null);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:MainMenuAction.java

示例8: findEditorKeys

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Attempt to find the editor keystroke for the given action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey) {
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    JTextComponent comp = getComponent();
    if (editorActionName != null && comp != null) {
        TextUI textUI = comp.getUI();
        Keymap km = comp.getKeymap();
        if (textUI != null && km != null) {
            EditorKit kit = textUI.getEditorKit(comp);
            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;
                    } else {
                        // try kit's keymap
                        Keymap km2 = ((BaseKit)kit).getKeymap();
                        KeyStroke[] keys2 = km2.getKeyStrokesForAction(a);
                        if (keys2 != null && keys2.length > 0) {
                            ret = keys2;
                        }                            
                    }
                }
            }
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:NbEditorToolBar.java


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