Java JTabbedPane backwardTab(final Component... component)

Here you can find the source of backwardTab(final Component... component)

Description

The focus goes back to the last component with CTRL + TAB.

License

Open Source License

Parameter

Parameter Description
component The focus goes back to the last component with CTRL + TAB

Declaration

public static void backwardTab(final Component... component) 

Method Source Code

//package com.java2s;
/* /*from   w  ww .j a  v  a2 s.  c  o  m*/
 * Copyright (C) 2014 GG-Net GmbH - Oliver G?nther
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.Component;
import java.awt.KeyboardFocusManager;

import java.awt.event.KeyEvent;
import java.util.Arrays;
import java.util.HashSet;

import javax.swing.KeyStroke;

public class Main {
    /**
     * The focus goes back to the last component with CTRL + TAB.
     * This Method does NOT override the default Traversal Keyset. Ensure that
     * the used components don't have the KeyEvents i.e. as forward traversal keys.
     * @param component The focus goes back to the last component with CTRL + TAB
     */
    public static void backwardTab(final Component... component) {
        for (Component component1 : component) {
            component1.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, new HashSet<KeyStroke>(
                    Arrays.asList(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK))));
        }
    }
}

Related

  1. checkHeavyWeightComponents(JTabbedPane tab)
  2. containsTab(JTabbedPane tabs, String name)
  3. createTabbedPane()
  4. findParentJTabbedPane(JComponent c)