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. Python rstrip() 方法

    描述 Python rstrip() 方法用于删除字符串尾部指定的字符,默认字符为所有空字符,包括空格.换行(\n).制表符(\t)等. 语法 rstrip() 方法语法: S.rstrip([cha ...

  2. opencv源代码分析:icvGetTrainingDataCallback简单介绍

    /* *函数icvGetTrainingDataCallback介绍 *功能:对全部样本计算特征编号从first開始的num个特征,并保存到mat里. *输入: *CvMat* mat矩阵样本总数个行 ...

  3. System Generator简介

    前言 System generator 安装之后会在Simulin模块库中添加一些Xilinx FPGA专用的模块库,包括Basic Element,Communication,Control Log ...

  4. 网络编程之TCP/UDP及其流程比较(转)

    TCP与UDP的区别 基于连接与无连接 对系统资源的要求(TCP较多,UDP少) UDP程序结构较简单 流模式与数据报模式TCP保证数据正确性,UDP可能丢包TCP保证数据顺序,UDP不保证 具体编程 ...

  5. OSGi中的ServletContext

    在OSGi中,不能的bundle分属不同的装载器(Class Loader), 在J2EE 应用中,不同BUNDLE 中的JSP 所相应的ServletContext对象不同,这与通常情况下的应用是不 ...

  6. 大数问题:求n的阶乘

    题目:求100! 这看起来是一个非常简答的问题,递归解之毫无压力 int func(int n){ if(n <= 1) return 1; else return n*func(n-1); } ...

  7. js中push和join方法使用介绍

    push和join方法想必大家并不陌生吧,在本文将为大家详细介绍下js中的push和join方法的使用.代码: <script type="text/javascript"& ...

  8. 简易C#动态加载dll(实现插件化)

    可以通过该方法来实现程序插件化. 假设A,B两个类,A类为宿主,B类为插件需要加载到A类中: class Program { public interface IHellow { void Hello ...

  9. lattice diamond 3.7安装破解

    第一步安装:执行.EXE文件,一直下一步,最后license选择没有USB什么的那个(具体记不清了). 第二步破解:安装完成后在环境变量中将license路径指定到license文件即可(LM_LIC ...

  10. [学习笔记]Spring依赖注入

    依赖: 典型的企业应用程序不可能由单个对象(在spring中,也可称之bean)组成,再简单的应用也是由几个对象相互配合工作的,这一章主要介绍bean的定义以及bean之间的相互协作. 依赖注入: s ...