disable tab key and auto edit other textfields

Posted on 2005-03-15
Medium Priority
Last Modified: 2008-01-09

1. How to disable the tab key in a JtextArea.

2. I have multiple JTextField say tx1,tx2,tx3,tx4.
Once I have enter the tx1 filed, or once my cursor goes to tx2 box, I wud like to auto complete the rest of tx2,tx3,tx4.

Assume that I already have an array of strings[][] to fill up the rest.
Question by:linchong
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 13552883
did you try this setFocusTraversalKeysEnabled function of JTextArea.


Accepted Solution

durgaprasad_j earned 600 total points
ID: 13552983
hi,  try this , you have to set FocusTraversalKeys for JTextArea

import javax.swing.*;
import java.awt.*;
import java.util.*;
public class test extends JFrame
      public test()
            JPanel jp1=new JPanel();
            this.setSize(new Dimension(400,400));
            JTextArea jta=new JTextArea("adfs adf adsf afd");
            jta.setPreferredSize(new Dimension(200,200));
            Set set = new HashSet(jta.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
            set.clear();   // Call clear() if you want to eliminate the current key set
            jta.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
            JTextArea jta2=new JTextArea("adfs adf adsf afd");
            jta2.setPreferredSize(new Dimension(200,200));
            Set set1 = new HashSet(jta2.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
            set1.clear();   // Call clear() if you want to eliminate the current key set
            jta2.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set1);
      public static void main(String args[])
            test a=new test();

Hope this helps

Expert Comment

ID: 13572036

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question