Java JTextComponent Tab disableTab(final JTextComponent txtComp)

Here you can find the source of disableTab(final JTextComponent txtComp)

Description

Disable the tab key for text components.

License

Open Source License

Declaration

public static void disableTab(final JTextComponent txtComp) 

Method Source Code

//package com.java2s;
/*****************************************************************************
 * Project: Droplet - Toolkit for Liquid Art Photographers
 * Copyright (C) 2012 Stefan Brenner/*from w  w w .  j a  v  a  2 s .  c om*/
 *
 * This file is part of Droplet.
 *
 * Droplet 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.
 *
 * Droplet 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 Droplet. If not, see <http://www.gnu.org/licenses/>.
 *****************************************************************************/

import java.awt.KeyboardFocusManager;

import javax.swing.text.JTextComponent;

public class Main {
    /**
     * Disable the tab key for text components.
     */
    public static void disableTab(final JTextComponent txtComp) {
        txtComp.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
        txtComp.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
    }
}

Related

  1. getTab(JTextComponent target)
  2. getTabSize(JTextComponent text)
  3. paintAboveline(Graphics g, JTextComponent tc, int pos0, int pos1)