e620. Activating a Keystroke When Any Component in the Window Has Focus
Normally, a keystroke registered to a component is activated when the component has the focus. This type of activation condition is called WHEN_FOCUSED. It is possible to specify that a keystroke be activated if any component (including itself) in the window has the focus. This type of keystroke activation condition is called WHEN_IN_FOCUSED_WINDOW.
Keyboard accelerators use this type of keystroke activation condition. For example, in many applications, regardless of which component has the focus, typing F1 in an active window causes a help window to appear.
There are three types of activation conditions available: WHEN_FOCUSED, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, and WHEN_IN_FOCUSED_WINDOW. When a key is typed, the focused component is checked for a registered keystroke to handle the typed key. If found, the action bound to the keystroke is invoked. If not found, the set of WHEN_ANCESTOR_OF_FOCUSED_COMPONENT keystrokes is searched for a handler of the typed key. WHEN_ANCESTOR_OF_FOCUSED_COMPONENT is described in e621 Activating a Keystroke When Any Child Component Has Focus. If none are found still, the set of WHEN_IN_FOCUSED_WINDOW keystrokes is searched for a handler of the typed key.
In non-WHEN_FOCUSED activated keystrokes, the source of the resulting action event is the component to which the keystroke is registered, not the focused component.
// To create an action, see e855 创建一个事件 // Register keystroke
component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke("F2"), action.getValue(Action.NAME)); // Register action
component.getActionMap().put(action.getValue(Action.NAME), action);
| Related Examples |
e620. Activating a Keystroke When Any Component in the Window Has Focus的更多相关文章
- e621. Activating a Keystroke When Any Child Component Has Focus
Normally, a keystroke registered on a component is activated when the component has the focus. This ...
- e614. Setting the Initial Focused Component in a Window
There is no straightforward way to set the initial focused component in a window. The typical method ...
- e610. Setting Focus Traversal Keys in a Component
When the focus is on a component, any focus traversal keys set for that component override the defau ...
- How a non-windowed component can receive messages from Windows -- AllocateHWnd
http://www.delphidabbler.com/articles?article=1 Why do it? Sometimes we need a non-windowed componen ...
- How a non-windowed component can receive messages from Windows
Why do it? Sometimes we need a non-windowed component (i.e. one that isn't derived fromTWinControl) ...
- windows消息机制详解(转载)
消息,就是指Windows发出的一个通知,告诉应用程序某个事情发生了.例如,单击鼠标.改变窗口尺寸.按下键盘上的一个键都会使Windows发送一个消息给应用程序.消息本身是作为一个记录传递给应用程序的 ...
- e858. 将键盘键和事件绑定
This example creates a number of keystrokes and adds them to the input map of a component. When a ke ...
- Scrapy爬虫入门系列3 将抓取到的数据存入数据库与验证数据有效性
抓取到的item 会被发送到Item Pipeline进行处理 Item Pipeline常用于 cleansing HTML data validating scraped data (checki ...
- Android系统onKeyDown监控/拦截/监听/屏蔽返回键、菜单键和Home键
在Android系统中用来显示界面的组件(Component)为Activity,也就是说只有重写Activity的onKeyDown方法来监控/拦截/屏蔽系统的返回键(back).菜单键(Menu) ...
随机推荐
- Zen Coding)官方文档 一览表
语法 Child: > nav>ul>li <nav> <ul> <li></li> </ul> </nav> ...
- linux命令(40):基础常用命令:cd,rm,mk
常用命令介绍 pwd,显示当前在哪个路径下 linux的用户管理 : useradd 用户名,添加用户 [案例]useradd xiaoming pas ...
- lua的模块加载require
加载指定的模块.首先函数会在 package.loaded 这个表中查看是否已经加载 了 modname 这个模块.如果是,那么 require 会返回保存在 package.loaded[modna ...
- Spring Boot(三):RestTemplate提交表单数据的三种方法
http://blog.csdn.net/yiifaa/article/details/77939282 ********************************************** ...
- 【Java】异常类处理层次
异常处理简介 异常在java的开发中可能没有那么被重视.一般遇到异常,直接上抛,或者随便catch一下处理之后对于程序整体运行也没有什么大的影响.不过在企业级设计开发中,异常的设计与处理的好坏,往往就 ...
- C语言版——点亮LED灯,深入到栈
在上一篇进行了汇编语言的编写之后,我们采用C语言来编写程序,毕竟C语言才是我们使用最多的语言. 仅仅是点亮LED灯显然太过于简单,我们需要分析最后的反汇编,了解函数调用栈,深入C语言骨髓去分析代码,并 ...
- Android Studio占用C盘内存
使用Android Studio的时候,会发现,在各种下载导入的时候,C盘内存耗费的非常的快,于是我看了下配置.
- 'Project Name' was compiled with optimization
'Project Name' was compiled with optimizationhtml, body {overflow-x: initial !important;}html { font ...
- 【Linux/CentOS】上手常见问题笔记
场景:Web项目服务端想要运行在Linux系统上,还要编写一些自动化发布代码的Shell脚本,需要学习使用Linux系统. 环境:Windows系统下用虚拟机VMware Workstation Pr ...
- 【微信小程序】Page页面跳转(路由/返回)并传参
页面跳转的方法参考官方文档: https://mp.weixin.qq.com/debug/wxadoc/dev/framework/app-service/route.html 问题:使用wx.na ...