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 ...
随机推荐
- 每日英语:The Toy Mogul Who Became A Billionaire Through His Fight To The Death With Barbie
The trophy case in the tiny conference room outside Isaac Larian’s corner office spans an entire wal ...
- Android 编程下的日志工具类
package com.sunzn.app.util; import android.util.Log; public class Logger { public static int DEBUG_L ...
- grpc-golang实现账号and密码认证
// I would recommend to use interceptors: // client grpc.Dial(target, grpc.WithPerRPCCredentials(&am ...
- HA&Federation【转】
转自:http://blog.csdn.net/tutucute0000/article/details/39756123 从nameNode1.namenode2克隆出namenode3.namen ...
- 玩转shell命令行
移动光标快捷键 ctrl+f 向前移动一个字符 ctrl+b 向后移动一个字符 ctrl+a 移动到当前行首home ctrl+e 移动到当前行尾end alt+f 向前移动一个单词 alt+b 向后 ...
- WIN锁屏+鼠标移动事件
winexec('rundll32.exe user32.dll, LockWorkStation', sw_hide); 1.shutdown.bat(关机) rundll32.Exe shell ...
- java将图片转换成二进制
package com.oumyye.图片; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; imp ...
- python 入门练习
1.猜拳游戏 import randomimport sys #from random import randintdef guess(): ubuntu = random.randint(0,2)# ...
- call_user_func_array 应用场景分析
1. 场景一 a.你要调用的函数名是未知的 b.要调用函数的参数类型及个数也是未知的 定时任务类需要定时运行一个函数,则接口就可以类似这样设计: /** * 在$run_time时刻运行$call_b ...
- centos 6.4 x86_64 (minimal) 编译安装percona
下载Percona-Server-5.5.24-26.0 wget https://www.percona.com/downloads/Percona-Server-5.5/Percona-Serve ...