e620. Activating a keystroke when all Component in the Window has Focus

Source: Internet
Author: User

Normally, a keystroke registered to a component was activated when the component had the focus. This type of activation condition is called WHEN_FOCUSED . It's possible to specify, a keystroke be activated if any component (including itself) in the window with 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 have the focus, typing F1 in an active window causes a Hel P window to appear.

There is 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 are 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 are searched for a handler of the typed key. are WHEN_ANCESTOR_OF_FOCUSED_COMPONENT described in e621 Activating a keystroke when any child Component have Focus. If None is 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 was the component to which the keystroke is Reg Istered, not the focused component.

    e855 Create an event        //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 all Component in the Window has Focus

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.