e621. Activating a Keystroke When Any Child Component Has Focus
Posted borter
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 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的主要内容,如果未能解决你的问题,请参考以下文章
beforecontent:"\e621",\e621是怎么来的
[问题] An error occurred while automatically activating bundle com.android.ide.eclipse.adt