码迷,mamicode.com
首页 > 移动开发 > 详细

e611. Setting Focus Traversal Keys for the Entire Application

时间:2018-09-06 10:55:14      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:lsp   stroke   tde   getc   cell   body   wan   strong   aci   

This example changes the focus traversal keys for the entire application. For an example of how to change the focus traversal keys for a particular component, see e610 Setting Focus Traversal Keys in a Component.

    // Change the forward focus traversal keys for the application
    Set set = new HashSet(
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(
            KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
    set.clear();   // Call clear() if you want to eliminate the current key set
    set.add(KeyStroke.getKeyStroke("F2"));
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
    
    // Change the backward focus traversal keys for the application
    set = new HashSet(
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(
            KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
    set.clear();   // Call clear() if you want to eliminate the current key set
    set.add(KeyStroke.getKeyStroke("F3"));
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set);
    
    // Remove all forward and backward focus traversal keys for the application
    set.clear();
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, set);

 

Related Examples

e611. Setting Focus Traversal Keys for the Entire Application

标签:lsp   stroke   tde   getc   cell   body   wan   strong   aci   

原文地址:https://www.cnblogs.com/borter/p/9596093.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!