Java JTabbedPane useTabToChangeFocus(Component comp)

Here you can find the source of useTabToChangeFocus(Component comp)

Description

use Tab To Change Focus

License

Open Source License

Declaration

static void useTabToChangeFocus(Component comp) 

Method Source Code


//package com.java2s;
import java.awt.Component;

import java.awt.KeyboardFocusManager;

import java.util.Arrays;

import java.util.HashSet;
import java.util.Set;

import javax.swing.KeyStroke;

public class Main {
    static void useTabToChangeFocus(Component comp) {
        Set<KeyStroke> strokes = new HashSet<KeyStroke>(Arrays.asList(KeyStroke.getKeyStroke("pressed TAB")));
        comp.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, strokes);
        strokes = new HashSet<KeyStroke>(Arrays.asList(KeyStroke.getKeyStroke("shift pressed TAB")));
        comp.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, strokes);
    }/*from  ww  w  .  j av a  2s .com*/
}

Related

  1. isInTabbedContainer(Component c)
  2. moveTab(JTabbedPane tabPane, int srcIndex, int dstIndex)
  3. selectTab(JTabbedPane pane, String title)
  4. setDefaultMnemonics(final JTabbedPane jtp)
  5. setSelectComponentTab(Component component)