Normally, a keystroke registered on 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 it or any child or descendant component has the focus. This type of keystroke activation condition is called WHEN_ANCESTOR_OF_FOCUSED_COMPONENT.

An example where this type of keystroke activation condition is useful is in the case of a scrollpane that handles scrolling navigation keystrokes even when the child component has the focus.

There are three types of activation conditions available: WHEN_FOCUSED, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, and WHEN_IN_FOCUSED_WINDOW. See e620 Activating a Keystroke When Any Component in the Window Has Focus for more details about these activation conditions.

    // To create an action, see e855 创建一个事件

    // Register keystroke
component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
KeyStroke.getKeyStroke("F2"), action.getValue(Action.NAME)); // Register action
component.getActionMap().put(action.getValue(Action.NAME), action);
Related Examples

e621. Activating a Keystroke When Any Child Component Has Focus的更多相关文章

  1. 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 ...

  2. [Angular 2] @ViewChild to access Child component's method

    When you want to access child component's method, you can use @ViewChild in the parent: Parent Compo ...

  3. [Vue] Parent and Child component communcation

    By building components, you can extend basic HTML elements and reuse encapsulated code. Most options ...

  4. vue & child component & props

    vue & child component & props vue pass data to child component https://vuejs.org/v2/guide/co ...

  5. react 函数子组件(Function ad Child Component)

    今天学习了react中的函数子组件的概念,然后在工作中得到了实际应用,很开心,那么好记性不如烂笔头,开始喽~ 函数子组件(FaCC )与高阶组件做的事情很相似, 都是对原来的组件进行了加强,类似装饰者 ...

  6. Vue Parent Send Ajax Data to Child Component

    Vue 父组件ajax异步更新数据,子组件props获取不到 2018年06月26日 09:25:06 哎哟嘿 阅读数 3585   当父组件  axjos  获取数据,子组件使用  props  接 ...

  7. [React] React Fundamentals: Accessing Child Properties

    When you're building your React components, you'll probably want to access child properties of the m ...

  8. 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 ...

  9. [React] Forward a DOM reference to another Component using forwardRef in React 16.3

    The function forwardRef allows us to extract a ref and pass it to its descendants. This is a powerfu ...

随机推荐

  1. NRF24L01使用外部中断读取数据的问题

    NRF24L01读取数据不能使用中断的方式,原因如下: 首先NRF24L01中断触发时,IRQ引脚会一直保持低电平直到状态寄存器中的中断标志被重新清零. stm32的外部中断触发方式只有上升沿或者下降 ...

  2. python中logging模块的使用

    一.基本用法 只需要基本的配置,就可以使用了. import logging def fun2(): logging.basicConfig(filename="fun2.log" ...

  3. ISE约束文件*.ucf的写法

    之前一直相不明白,为什么从官网下载的AC97的IP不能跑起来,整个IP就像空壳一样,bit_clk输进去,没有任何信号输出来.从IP的RTL来看,即使是IP不连到CPU的BUS上,只要是综合进FPGA ...

  4. ClickAndMoveTest

    关于ccTouchesEnded看这个博客即可 http://blog.linguofeng.com/archive/2012/09/12/cocos2d-x-touch.html class Cli ...

  5. CString转char * ,string

    CString头文件#include <afx.h> string头文件#include <string.h> 1.CString转char * CString cstr; c ...

  6. The power of now

    惊喜的发现,在这个短暂而又漫长的盛夏里心情开始随天气而变了(*^__^*) ...... <秘密>和<当下的力量>两者都一样,看起来费劲,不过还真的有点道理. <冰与火之 ...

  7. 解决老是提示找不到Mapper文件无法执行定义的方法问题!

    尼玛,被mybatis的*Mapper.xml文件害惨了!整整两天都在围绕这个问题转圈! 先看问题长啥样吧!下面是通过逆向工程生成的Mapper.xml文件,包路径什么的都没有错! 但是每次调用Map ...

  8. GNU风格 ARM汇编语法5

    . GNU汇编程序中的常数 <>十进制数以非0数字开头,如:123和9876: <>二进制数以0b开头,其中字母也可以为大写: <>八进制数以0开始,如:,: &l ...

  9. Oracle_字符集问题(数据库与客户端字符集关联关系)

    http://blog.163.com/jiankun_liu/blog/static/1863927762013698175289 ********************************* ...

  10. 7处ff与ie中读写html、css相关属性的不同之处

    1. float样式属性 IE syntax: document.getElementById("test").style.styleFloat = "left" ...