how to move curosr from one text field to another automatically when the first textfield reaches its maximum length

how to move curosr from one text field to another automatically when the first textfield reaches its maximum length

how to move curosr from one text field to another automatically when the first textfield reaches its maximum length

View Answers

December 11, 2010 at 3:33 PM

Hi Friend,

Here we have created a program where if the user exceeds the limit of six characters in the first text filed, then the cursor automatically moved to the second one.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class MoveCursor{
    public static void main(String[]args){
     JLabel lab1=new JLabel("Name");
     JLabel lab2=new JLabel("Address");
     final JTextField text1=new JTextField(20);
     final JTextField text2=new JTextField(20);
     JPanel p=new JPanel(new GridLayout(2,2));
     JFrame f=new JFrame();
     p.add(lab1);
     p.add(text1);
     p.add(lab2);
     p.add(text2);
     f.add(p);
     f.setVisible(true);
     f.pack();
     text1.addKeyListener(new KeyAdapter(){
          public void keyPressed(KeyEvent e){
          String value=text1.getText();
          if(value.length()==5){
          text2.requestFocus();
            }
          }
     });
    }
    }

Thanks









Related Tutorials/Questions & Answers:
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length  how to move curosr from one text field to another automatically when the first textfield reaches its maximum
automatically move next page when data fetched from database is stored in text field
automatically move next page when data fetched from database is stored in text... are stored in database wherein when the in the first text field the data is already stored when data in second text is tried to enter or automaticaaly fetched
Advertisements
how to move records from one table to other based on its creation time
how to move records from one table to other based on its creation time  Hi all,, As part of my requirement ,the records in one table have to move... not be present in first table after creation of two days,and it has to move
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..  how to output text from comboBox from first frame to textField on the second frame? please help me
How to prevent from navigating to ck buttonnext page when user reaches login page using back button
How to prevent from navigating to ck buttonnext page when user reaches login... 2)Page with link to open pdf files When i lo-gin,it takes me to 2nd page where there are buttons that opens pdf files in new window.The problem is when i
how to move pointer in Textfield to newline
how to move pointer in Textfield to newline  consider my case...; class Table1 extends Frame implements ActionListener{ TextField tf1,tf2,tf3...(100,10,200,30); Label l2=new Label("Enter the value to get its Table
How to navigate from one jsf to another in eclipse
How to navigate from one jsf to another in eclipse  Hi there is my jsf code... <%@ page language="java" contentType="text/html; charset... is working fine in NETBEANS.. but when i run this in eclipse it stays on the first
how to pass a string from one class to another
how to pass a string from one class to another  hi all, Good morning... string from one class to another. import java.util.*; class A{ static String... string from one class to another. import java.io.*; class Class1 { public
How to forward the control from one jsp to another?
How to forward the control from one jsp to another?  Hi... other.i.e. First JSP is communicating with the second JSP, Second JSP is not communicate with the Third JSP. I want forward the control from first jsp to second
how to highlight the field in image,when i have entered into that corresponding field's textbox-any one help out
how to highlight the field in image,when i have entered into that corresponding field's textbox-any one help out  how to highlight the field in image,when i have entered into that corresponding field's textbox. Here webpage
swings:how to link from one form to another form
swings:how to link from one form to another form  how to link from one form to another form
How to pass variable from one class to another in java
How to pass variable from one class to another in java  How to pass variable from one class to another in java?   Example: public class...() { System.out.println("Welcome in " + name + " Its id number : " + IdNo); } public
how to copy file from one directory to another in java with examples
how to copy file from one directory to another in java with examples  how to copy file from one directory to another in java with examples? I want... copy from one directory to another in java. Thanks
how to go from one frame to another frame in swings - Java Beginners
how to go from one frame to another frame in swings  Hi, My task is to go from one frame to another.......... let us think that iam having two buttons on a frame........button names are ok and next........ when iam clicking
Copy data from one JTextField to another JTextField
, you will learn how to copy the data from one JTextField into another... Copy data from one JTextField to another JTextField..._TO_REPLACE_2 Enter some data into first text field (cell1). Highlight all
how to pass an array from one jsp to another jsp - JSP-Servlet
how to pass an array from one jsp to another jsp  hi friedns, can any One tell me how to send an array from one jsp to another jsp,pls any one send the code for this.also porvid the code how to retrive the arry in another jsp
textfield selected text
textfield selected text  How to select text in text field
how to write function of copy from one to another location in this code
how to write function of copy from one to another location in this code  I need to write a code to copy a file from one location to another using browse button in it. i have written code for the browse button. please help me
Drag and Drop components from one frame to another frame
Drag and Drop components from one frame to another frame... button etc.) from one frame to another frame. In this code we have used..., user can drag and drop component from one to another frame. Download Source
How To Pass data from one GUI to another in java swing
How To Pass data from one GUI to another in java swing  I'm new to java and part of our assignment is to build a GUI and display a result set from data input. I'm stuck at how to get the user's input from JTextFields and combobox
MX Move Effect in Flex4
MX Move Effect in Flex4: The component move from one point to another point by using Move effect. You will set the xFrom, yFrom, xTo, yTo, xBy and yBy... see how we can use a Move effect With components. Example: <?xml
Spark Move Effect in Flex4
Spark Move Effect in Flex4: The component move from one point to another point by using Move effect. You will set the xFrom, yFrom, xTo, yTo, xBy and yBy...; In this example you can see how we can use a Move effect With components
update one table from another table
update one table from another table  hello, i need to update one.... for example TotalQuantity field from Products table should be updated if i enter the Quantity field in table 'Products_Purchased'In table 'Products' one item
how to use one form out of multiple form from one jsp to another jsp
how to use one form out of multiple form from one jsp to another jsp  Hi All. please give me your valuable advise for below requirement.. I have... one form from abc.jsp as it is to another .jsp(say def.jsp).Your advise
TextField
TextField       A scrollable text display object with one row of characters is known as the TextField. In the example given below, shown a textfield in the applet by creating its
AlertViewWithPassWord iPhone
Box when text field is empty and the AlertView is Consist of Two textfield one... when text field is empty will add some codes in .h and .m file and will show... to enter text we need TextField and to enter the Password we need text field
JMF: How trigger event when player reaches certain time playing a video?
JMF: How trigger event when player reaches certain time playing a video?  How to code in Java (with Java Media Framework): When the player reaches a certain time playing a video clip (for example, reaching 3.124 minutes
passing data from one jframe to another
passing data from one jframe to another  I have two JFrame,built by using the GUI Editor netbeans 6.9.i have to pass a data from a Jtextfield in the first Jframe to another JLabel in the other JFrame.Can you please help me,how
calling one jsp from another jsp page
calling one jsp from another jsp page  need coding for calling one jsp from another jsp including the xml file.Its urgent
take data from one table and insert same in another
take data from one table and insert same in another  I want to know when a new field update in table and the same data has to update in another table
Text Field Midlet Example
Text Field MIDlet Example       This example illustrates how to insert text field in your form... the form with name and company field. The TextField
File copy from one directory to another in java
File copy from one directory to another in java  I am trying to find very good code example for copying a file from one directory to another... from a directory to another directory. How to achieve this? Is there any API
how to use string of one class into another Class
how to use string of one class into another Class  I created textField(JTextField t1=new JTextField();(it is in ClassA. The input of this textField i.e t1.getText() is to be used in different(another Class say in ClassB. How can
How to copy files from one folder to another based on lastmodified date - Java Beginners
Copy files from one folder to another  How to copy files from one folder to another based on lastmodified date
How to make a servlet to automatically call another servlet at some time instant.
How to make a servlet to automatically call another servlet at some time instant.  Can some one assist me How to make a servlet to automatically call another servlet at some time instant. currently I have a single servlet which
how to pass arraylist data from one jsp to another jsp - JSP-Servlet
how to pass arraylist data from one jsp to another jsp  hi to all iam... the following >XXX/ ? is required to send a value from one jsp to another... to receive all employee id's that are retrived from the database in the first jsp
to bring checked data from one page to another
to bring checked data from one page to another  thanks for your help... there is one jsp page , on it there is a link, on click of which it is opening second... fetching data from the database on second jsp page with checkbox corresponding each
how to enable textfield in j2me netbeans when a choice element is selected?
how to enable textfield in j2me netbeans when a choice element is selected?  How to enable a textfield in j2me using netbeans when a choice element is selected and how to keep it disabled when any choice element corresponding
how to enable textfield in j2me netbeans when a choice element is selected?
how to enable textfield in j2me netbeans when a choice element is selected?  How to enable a textfield in j2me using netbeans when a choice element is selected and how to keep it disabled when any choice element corresponding
how to scrape the data from one website another website using html dom parsing in php
how to scrape the data from one website another website using html dom parsing in php  " how to scrape the data from one website another website using html dom parsing in php" i'm trying this one .please provide code for me
calling one jap page from another jsp page
calling one jap page from another jsp page  i created a button in one jsp page i need to call another jsp page as an action to that button. so how can i call.. plz any one explain. its urgent
copying data from one table to another
copying data from one table to another  i need to copy data from one table to another table.. i.e the 1st eid of employee table must be copied to the 1st eid in appusers table, 2nd eid of employee to the 2nd eid of appusers
how can retrieve more than one values in text field using ajax?
how can retrieve more than one values in text field using ajax?  im... first then in mysql db retrieve seat numbers 1,2,3,4 in text boxes problem...($result)) { echo "<input name='seat' type='text' value=".$row['Seat_Number
iphone text field example
to see...how to add the value of two different textfield and printing it in another textfield. This is a quite easy! What all we have to do is to take three... textFields used in this application, First 2 takes the input from the user and the last
Moving file or directory from one directory to another
Moving file or directory from one directory to another... directory is moved from one directory to another directory. This program... from one directory to another. In this section an example is given
Maximum length of Session ( $_SESSION ) in PHP.
Maximum length of Session ( $_SESSION ) in PHP.  sir, i want to know that how much limit of storing data into session in php. i mean can i store full product descriptions into session. Thank u
How to solve concurrency issue when an application is running on two machine to fetch record from one database
How to solve concurrency issue when an application is running on two machine to fetch record from one database  I have developed an application in java to run on two machines. Program will fetch a record from database and process
How to copy files from one folder to another based on lastmodified date - Java Beginners
How to copy files from one folder to another based on lastmodified date  I have to make a simple utility to copy files from a folder to another folder in the same hierarchy, without overwriting the existing.  hiimport
calling one jsp from another jsp - JSP-Servlet
calling one jsp from another jsp  Hi All, In my web application... file's method processor should move to the one.jsp file and start executing from... in two.jsp by using jsp declarative tag. Now from one.jsp file I want to call
How can java programs execute automatically when it connects to network
How can java programs execute automatically when it connects to network  Good Day dears... How can java programs execute automatically when it connects to network. Thanks in Advance friends Shackir   How can i Test

Ads