zoukankan      html  css  js  c++  java
  • e858. 将键盘键和事件绑定

    This example creates a number of keystrokes and adds them to the input map of a component. When a keystroke is added to an input map, an action name must be supplied. This action is invoked when the keystroke is pressed while the component has the focus.

        // Create some keystrokes and bind them all to the same action
        component.getInputMap().put(KeyStroke.getKeyStroke("F2"), "actionName");
        component.getInputMap().put(KeyStroke.getKeyStroke("control A"), "actionName");
        component.getInputMap().put(KeyStroke.getKeyStroke("shift F2"), "actionName");
        component.getInputMap().put(KeyStroke.getKeyStroke('('), "actionName");
        component.getInputMap().put(KeyStroke.getKeyStroke("button3 F"), "actionName");
        component.getInputMap().put(KeyStroke.getKeyStroke("typed x"), "actionName");
        component.getInputMap().put(KeyStroke.getKeyStroke("released DELETE"), "actionName");
        component.getInputMap().put(KeyStroke.getKeyStroke("shift UP"), "actionName");
        
        // Add the action to the component
        component.getActionMap().put("actionName",
            new AbstractAction("actionName") {
                public void actionPerformed(ActionEvent evt) {
                    process(evt);
                }
            }
        );
    
    Related Examples
  • 相关阅读:
    关于python列表中的赋值问题
    $' ': command not found报错问题
    0day安全-软件漏洞分析技术(第二版)——Crack实验一
    PNI12927 学习笔记
    Mini2440串口通信之DMA
    Mini2440串口通信
    Mini2440的外部中断编写
    VM中设置redhat为静态IP
    ldr指令小记
    Makefile文件编写小记
  • 原文地址:https://www.cnblogs.com/borter/p/9596117.html
Copyright © 2011-2022 走看看