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 ...
随机推荐
- openfire维持在线状态,监听消息
public static void testLoginStatus()throws XMPPException,InterruptedException { AccountManager accou ...
- LeetCode: String to Integer (atoi) 解题报告
String to Integer (atoi) Implement atoi to convert a string to an integer. Hint: Carefully consider ...
- TextView
wrap_content 设置TextView的宽度和高度为 wrap_content,则其大小会自动适应文本. textSize 设置字体大小 textColor 设置字体颜色 <TextVi ...
- JAVA-数据库之查询记录
相关资料:<21天学通Java Web开发> ResultSet结果集1.使用exectteQuery()方法查询数据.2.exectueQuery()方法接收一个查询SQL语句.3.返回 ...
- 2. K-Means的优化
1. K-Means原理解析 2. K-Means的优化 3. sklearn的K-Means的使用 4. K-Means和K-Means++实现 1. 前言 上一篇博文K-Means原理解析简单清晰 ...
- 修改zerolog使log输出的文件名可以在goland里自动定位--技巧
如何自动定位文件 最近发现goland会自动识别输出的文件或者url,但是有时候又识别不出来,折腾了一下,发现原来要求文件路径或url两边要有空格 改造zerolog 既然如此,那么让我们来改造一下z ...
- JDBC插入数据超长时无法自动截断问题
问题 JDBC操作MySQL数据库,当进行插入或更新操作的数据长度超过表字段的声明最大长度时,会报出以下错误,导致不能正常插入: 但是当直接在MySQL客户端操作时,发现确实可以的,只不过会自动对插入 ...
- 依赖注入(Dependency Injection)
Spring的两个核心内容为控制反转(Ioc)和面向切面(AOP),依赖注入(DI)是控制反转(Ioc)的一种方式. 依赖注入这个词让人望而生畏,现在已经演变成一项复杂的编程技巧 或设计模式理念.但事 ...
- C语言 · 色盲的民主
算法提高 色盲的民主 时间限制:1.0s 内存限制:256.0MB 问题描述 n个色盲聚在一起,讨论一块布的颜色.尽管都是色盲,却盲得各不相同.每个人都有自己的主张,争论不休.最终, ...
- python 3 操作mysql数据库的方法
参考:http://www.cnblogs.com/txw1958/archive/2012/07/22/python3-mysql.html http://www.jb51.net/article/ ...