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. Spring横切面(advice),增强(advisor),切入点(PointCut)(转)

    Spring横切面(advice),增强(advisor),切入点(PointCut)的一点理解: 1.Spring管理事务有2种,其中一种是HibernateTransactionManager管理 ...

  2. enumerate的简单使用

    l = [11,22,33,55,"ss","zz"] for i,v in enumerate(l): print(i,v) #打印结果: # 0 11 # ...

  3. .NET执行SQL插入时间的问题

    错误描述: 一个项目,源码是BOSS给的,部署到网上了,运行没有问题,可是在本地运行,就会有问题,问题在于往一些表插入记录的时候,本地不管怎么样都插入不了,而网上就可以插入,都是相同的一份代码 解决: ...

  4. 【Android】3.4 图层展示

    分类:C#.Android.VS2015.百度地图应用: 创建日期:2016-02-04 3.4 示例4--图层展示 一.简介 1.地图类型 百度地图Android SDK 3.7.1提供了两种类型的 ...

  5. 玩转oracle学习第七天

     1.上节回想 2.PL/SQL的进阶 3.oracle的视图 4.oracle的触发器 目标: 1.掌握PL/SQL的高级使用方法(能编写分页过程模块,下订单过程模块.. . ) 2.会处理or ...

  6. CentOS 64位下安装Postfix+Dovecot 配置邮件server笔记

    Postfix 和Dovecot功能确实非常强大,支持各种认证方式, 配置非常灵活, 就由于太过于灵活, 反而安装配置的过程中,easy有各种各样的陷阱,碰到问题了. 日志是最好的解决的方法了.    ...

  7. Linux /proc目录详解

    Linux系统上的/proc目录是一种文件系统,即proc文件系统.与其它常见的文件系统不同的是,/proc是一种伪文件系统(也即虚拟文件系统),存储的是当前内核运行状态的一系列特殊文件,用户可以通过 ...

  8. 使用B或BL跳转时,下一条指令的地址的计算

    .text .global _start 3_start: b step1 step1: ldr pc, =step2 step2: b step2 反汇编代码: : eaffffff b 0x4 : ...

  9. iptables进行DNAT(目标地址转换)

    前言:对于Linux服务器而言,一般服务器不会直接提供公网地址给用户访问,服务器在企业防火墙后面,通常只是暴露一个公网给用户,下面已80端口进行实现. 演示环境:VM (1)host: 172.16. ...

  10. FreeRTOS 低功耗之待机模式

    STM32F103 如何进入待机模式在 FreeRTOS 系统中,让 STM32 进入待机模式比较容易,调用固件库函数PWR_EnterSTANDBYMode 即可. STM32F103 如何退出待机 ...