e860. 列出组件绑定的键盘键
This example demonstrates how to list all the key bindings in a component. Text components have an additional set of key bindings called a keymap. See e1005 列出JTextComponent中键盘映射绑定的键 for an example on how to list those key bindings.
// List keystrokes in the WHEN_FOCUSED input map of the component
InputMap map = component.getInputMap(JComponent.WHEN_FOCUSED);
list(map, map.keys());
// List keystrokes in the component and in all parent input maps
list(map, map.allKeys()); // List keystrokes in the WHEN_ANCESTOR_OF_FOCUSED_COMPONENT input map of the component
map = component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
list(map, map.keys());
// List keystrokes in all related input maps
list(map, map.allKeys()); // List keystrokes in the WHEN_IN_FOCUSED_WINDOW input map of the component
map = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
list(map, map.keys());
// List keystrokes in all related input maps
list(map, map.allKeys()); public static void list(InputMap map, KeyStroke[] keys) {
if (keys == null) {
return;
}
for (int i=0; i<keys.length; i++) {
// This method is defined in e859 将键盘事件和字符串对应
String keystrokeStr = keyStroke2String(keys[i]); // Get the action name bound to this keystroke
while (map.get(keys[i]) == null) {
map = map.getParent();
}
if (map.get(keys[i]) instanceof String) {
String actionName = (String)map.get(keys[i]);
} else {
Action action = (Action)map.get(keys[i]);
}
}
}
Related Examples |
e860. 列出组件绑定的键盘键的更多相关文章
- GUI按键绑定到键盘和打印组件
首先说明一点 按键绑定到键盘和设置快捷键是不一样的 按键绑定键盘是按键有了和button一样的功能,没有焦点时也能使用(WHEN_IN_FOCUSED_WINDOW),甚至有时候单独作为一个事件(有自 ...
- KnockoutJS 3.X API 第六章 组件(3) 组件绑定
组件绑定将指定的组件注入到元素中,并且可选地将参数传递给它. 本节目录 一个例子 API 组件生命周期 备注1:仅限模板组件 备注2:使用没有容器元素的组件 备注3:将标记传递给组件 处置和内存管理 ...
- Angular4.x 创建组件|绑定数据|绑定属性|数据循环|条件判断|事件|表单处理|双向数据绑定
Angular4.x 创建组件|绑定数据|绑定属性|数据循环|条件判断|事件|表单处理|双向数据绑定 创建 angular 组件 https://github.com/angular/angular- ...
- Vue--vue中的组件、组件绑定事件和数据、私有组件、子组件,父子组件参数互传
一.公有组件以及组件的使用和特点 <!DOCTYPE html> <html lang="en"> <head> <meta charse ...
- 键盘键与虚拟键码对照表+delphi虚拟键码对应关键
键盘键与虚拟键码对照表 字母和数字键 数字小键盘的键 功能键 其它键 键 键码 键 键码 键 键码 键 键码 A 65 0 96 F1 112 Backspace 8 B 66 1 97 F2 113 ...
- js键盘键值大全
原文地址:http://blog.csdn.net/avenccssddnn/article/details/7950524 js键盘键值 keycode 8 = BackSpace BackSpac ...
- vue中组件绑定事件时是否加.native
组件绑定事件时 1. 普通组件绑定事件不能添加.native, 添加后事件失效 2. 自定义组件绑定事件需要添加.native, 否则事件无效 <template> <!-- < ...
- Vue组件绑定自定义事件
Vue组件使用v-on绑定自定义事件: 可以分为3步理解: 1.在组件模板中按照正常事件机制绑定事件: template: '<button v-on:click="increment ...
- vuejs给组件绑定原生事件
给组件绑定事件,该事件是自定义的事件 <div id='root'> <child @click='handleClick'></child> </div&g ...
随机推荐
- 【DIOCP开源项目】实际应用案例
案例1 DIOCP是Delphi下进行IOCP服务端通讯开发的一个非常好的开源框架,稳定.高效并且使用起来十分简单. 自己两个多月之前因为需要使用Delphi开发一个TCP服务端,当时也是到处爬文,希 ...
- vs code 快捷键的使用
vs code 快捷键的使用 shift + f12 快速查找函数的生成Ctrl+F12 查看单个函数的定义Shift+F12 查看所有函数的定义ctrl + ` 是打开运行的程序ctrl + Tab ...
- Mac使用pyenv安装Python出现The Python zlib extension was not compiled. Missing the zlib错误
Mac使用pyenv安装Python出现The Python zlib extension was not compiled. Missing the zlib错误 参考这里,详细如下: On Mac ...
- Python3之pymysql导入mysql
$cat insert.py #!/usr/bin/python # -*- coding: UTF-8 -*- import os import sys import datetime import ...
- Linux命令之stty
用途说明 stty命令用于显示和修改终端行设置(change and print terminal line settings). 常用参数 stty命令不带参数可以打印终端行设置,加上-a参数可以打 ...
- idea 同project添加多个module maven支持
选中新项目的pom.xml 会识别maven项目
- java 泛型详解-绝对是对泛型方法讲解
Reference: http://blog.csdn.net/s10461/article/details/53941091 1. 概述 泛型在java中有很重要的地位,在面向对象编程及各种设计模 ...
- [转]Spring MVC 教程,快速入门,深入分析
原文地址:http://elf8848.iteye.com/blog/875830 目录 一.前言 二.spring mvc 核心类与接口 三.spring mvc 核心流程图 四.spring mv ...
- Bootstrap Popover 隐藏的Javasript方法
Bootstrap Popover是Bootstrap的弹出提示控件.我们可以通过data属性或者Javascript来调用该控件.data属性调用定制性较差这里就不细说了,我们讲一下Javascri ...
- lateral view
原文地址:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+LateralView# lateral view用于和spl ...