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 ...
随机推荐
- Gluster vs Ceph:开源存储领域的正面较量
https://www.oschina.net/news/49048/gluster-vs-ceph 引言:开源存储软件Ceph和Gluster能够提供相似的特性并且能够为用户节省不小的开支.那么谁更 ...
- 漫游Kafka之过期数据清理【转】
转自:http://blog.csdn.net/honglei915/article/details/49683065 Kafka将数据持久化到了硬盘上,允许你配置一定的策略对数据清理,清理的策略有两 ...
- 【Android】输入设备配置文件(.idc文件)
何为idc idc(Input Device Configuration)为输入设备配置文件,它包含设备具体的配置属性,这些属性影响输入设备的行为. 对于touch screen设备,总是需要一个id ...
- vue 的事件冒泡
一.事件冒泡 方法一.使用event.cancelBubble = true来组织冒泡 <div @click="show2()"> <input type=&q ...
- 转:安装Chrome不成功,显示代码为“0xa0430721”的解决办法
转自:https://www.douban.com/note/475994923/ Step1: Open your Application Data Folder. For Windows XP: ...
- Nginx作为反向代理服务器
前言:Nginx通过proxy模块实现反向代理功能.在作为web反向代理服务器时,nginx负责接收客户请求,并能够根据URI.客户端参数或其它的处理逻辑将用户请求调度至上游服务器上(upstream ...
- js使用正则替换掉所有的“”
需求,使用bootstrap 的 summernote上传图片,转换成文件流,上传给后台,上传用json传送,不能有“” content = content.replace(/\"/ig,& ...
- Java 1.7 ThreadPoolExecutor源代码解析
相比1.6,1.7有些变化: 1. 添加了一个TIDYING状态.这个状态是介于STOP和TERMINATED之间的.假设运行完terminated钩子函数后状态就变成TERMINATE ...
- Java输出字符串格式问题 .UnknownFormatConversionException
今天遇到一个问题,使用JSoup挖掘出的数据一直出错 Exception in thread "main" java.util.UnknownFormatConversionExc ...
- IBatis批量插入数据
IBatis插入注意,数据量比较多的花,需要分批插入,策略是dao里面控制插入批次,mapper里面批量插入即可 @Override public Long insertBatch(List<W ...