Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions how to move curosr from one text field to another automatically when the first textfield reaches its maximum length
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vikas
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length
1 Answer(s)      3 years and 10 months ago
Posted in : Java Interview Questions


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


Advertisement
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 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 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 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
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
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 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
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
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
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
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
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
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
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
textfield selected text
textfield selected text  How to select text in text field
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... data into first text field (cell1). Highlight all the text in first cell
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
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... that how to drag and drop component (drop down list, text area, check box, radio button etc.) from one frame to another frame. In this code we have used
iphone text field example
in this application, First 2 takes the input from the user and the last text field... is first textfield and second is another.*/  ... to see...how to add the value of two different textfield and printing
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
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
AlertViewWithPassWord iPhone
Box when text field is empty and the AlertView is Consist of Two textfield one... name is AlertView, is view based Application. To show Alert view when text field... need TextField and to enter the Password we need text field and also Button
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
How to Define Text Field Validation iPhone
How to Define Text Field Validation iPhone  Hi, Can anybody explain me how to define textfield validation iPhone program. please phone online help reference or example. Thanks
 

 

 

DMCA.com