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) ...
随机推荐
- Market Guide for AIOps Platforms
AIOps platforms enhance IT operations through greater insights by combining big data, machine learni ...
- 21、uwp UI自动化测试(WinAppDriver)
使用 UI自动化测试的好处就是在代码逻辑中写好 case 后,来实现 “一劳永逸” 的作用,并且自动化测试能够模拟人工达不到要求,比如快速切换页面.快速点击按钮等,对于提高软件的稳定性很有帮助. 安装 ...
- zookeeper的原理讲解
留着以后看:http://blog.csdn.net/u010311445/article/category/1677839
- Mac上把python源文件编译成so文件
把python源文件编译成so文件 前言 实际上属于一种代码混淆/加密的技术,大家知道python的源文件放在那里,大家是都可以看的,不像C语言编译出来可以拿编译后的东西去运行,所以就出现了这种需求. ...
- WebService中方法的重载
阅读目录 一:WebService中的方法是否允许重载? 二:为什么WebService中不支持方法的重载? 三:如何解决WebService中方法的重载? 一:WebService中的方法是否允许重 ...
- git stash 暂存恢复和文件误删恢复
git commit提交文件,服务器返回本地文件有修改. 1.git stash :暂存本地代码 2.git pull origin develop : 获取远程分支代码 3.git stash po ...
- DjangoUeditor 使用七牛云存储
DjangoUeditor 是一个相当赞的django 富文本编辑器,你可以在 https://github.com/zhangfisher/DjangoUeditor 查看相关信息. 我一直想着把D ...
- C#学习笔记(19)——使用IComparer(百度文库)
说明(2017-7-24 19:15:15): 1. 百度文库里的一篇文章,觉得讲的比较好.原文地址:https://wenku.baidu.com/view/b53cd250ad02de80d4d8 ...
- 3. 文本相似度计算-DSSM算法
1. 文本相似度计算-文本向量化 2. 文本相似度计算-距离的度量 3. 文本相似度计算-DSSM算法 4. 文本相似度计算-CNN-DSSM算法 1. 前言 最近在学习文本相似度的计算,前面两篇文章 ...
- 插入中国所有省和市的SQL语句--以后用
需要做根据省市过滤查询的,不得已写入数据库,这个留着方便以后用. 首先创建两张表 drop database if exists BSM; create database BSM; use BSM; ...