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 |
e858. 将键盘键和事件绑定的更多相关文章
- Geckofx 45 正确模拟键盘输入的事件绑定方法
var inputs = selection.GetElementsByTagName("input").Select(p => p as Gecko.DOM.GeckoIn ...
- Dojo初探之4:dojo的event(鼠标/键盘)事件绑定操作(基于dojo1.11.2版本)
前言: 上一章详解了dojo的dom/query操作,本章基于dom/query基础上进行事件绑定操作 dojo的事件 dojo的事件绑定操作分为鼠标和键盘两种进行详解 1.鼠标事件 我们沿用上一章中 ...
- js对键盘输入事件绑定到特定按钮
转自:https://www.cnblogs.com/liluping860122/archive/2013/05/25/3099103.html<script type="text/ ...
- [转] js对键盘输入事件绑定到特定按钮。
<script type="text/javascript" language="javascript"> document.onkeyup = f ...
- 捕获enter键盘事件绑定到登录按钮
/** *捕获enter键盘事件绑定到登录按钮 */ function keyLogin(event) { if (event.keyCode == 13) { document.getElement ...
- js Dom为页面中的元素绑定键盘或鼠标事件
html鼠标事件 onload 页面加载 onclick 鼠标单击 onmouseover 鼠标移入 onmouseout 鼠标移出 onfocus 获取焦点 onblur 失去焦点 onchange ...
- 通过键盘上下键 JS事件,控制候选词的选择项
效果图 JS代码 //上下键 选择事件 searchBackgroud 为样式,只做标记,无实质样式,因为和其他样式不兼容,只能添加CSS $(document).keydown(function ( ...
- js 获取当前焦点所在的元素、给元素和input控件添加键盘监听事件、添加页面级的键盘监听事件
页面级的键盘监听事件 document.onkeydown = function (event) { var e = event || window.event || arguments.callee ...
- dojo事件驱动编程之事件绑定
什么是事件驱动? 事件驱动编程是以事件为第一驱动的编程模型,模块被动等待通知(notification),行为取决于外来的突发事件,是事件驱动的,符合事件驱动式编程(Event-Driven Prog ...
随机推荐
- 支付宝对账单下载Java正式商户调用
package code; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; impo ...
- C++11 类型推导decltype
我们之前使用的typeid运算符来查询一个变量的类型,这种类型查询在运行时进行.RTTI机制为每一个类型产生一个type_info类型的数据,而typeid查询返回的变量相应type_info数据,通 ...
- CentOS6.5 安装Nexus配置Maven私服
1.下载Nexus的tar包,链接地址.注意,3.x版本需要JDK版本1.8及以上版本. 2.创建安装包存放目录 命令:mkdir -p /usr/local/src/installs 3.rz或者f ...
- 【神经网络】Reducing the Dimensionality of Data with Neural Networks
这篇paper来做什么的? 用神经网络来降维.之前降维用的方法是主成分分析法PCA,找到数据集中最大方差方向.(附:降维有助于分类.可视化.交流和高维信号的存储) 这篇paper提出了一种非线性的PC ...
- MVC3中输出Html标签的方法
想要输出html,可以三种方式:@Html.Raw(a)@MvcHtmlString.Create(a)@{WriteLiteral(a);} @(new HtmlString( "< ...
- java基础篇---Servlet监听器
在写此篇前,看了一下园友写的,感觉其基础知识归纳的十分全面,我在此就不累赘的写了,链接地址(http://www.cnblogs.com/sherryueda/p/4273169.html), 我就写 ...
- [转]mysql 行转列 列转行
原文地址:http://www.cnblogs.com/xiaoxi/p/7151433.html 一.行转列 即将原本同一列下多行的不同内容作为多个字段,输出对应内容. 建表语句 DROP TABL ...
- 关于python最大递归深度 - 998
今天LeetCode的时候暴力求解233 问题: 给定一个整数 n,计算所有小于等于 n 的非负数中数字1出现的个数. 例如: 给定 n = 13, 返回 6,因为数字1出现在下数中出现:1,10,1 ...
- C#使用双缓存减少界面闪烁
场景:一个panel中动态加载多个自定义控件item,类似QQ聊天窗口 问题:加载panel时界面会卡顿,先显示阴影再显示界面:移动滚动条时item会闪烁 解决方法: panel 添加方法,减少界面闪 ...
- Linxu 学习记录
1.配置Java人环境变量,设置后需要使用命令: source /etc/profile 让配置立即生效. # jdk7 settings JAVA_HOME=/usr/jdk1..0_79 JRE_ ...