My application has four TextArea, and I want to enter only four characters in one area of ββthe text, and the cursor will automatically move to the next TestArea. Again, when I enter four characters into this TextArea, then again the cursor will automatically move to the next TextArea.
Example: during the installation of Window XP, it wants βKeyβ, and there are four sections when you enter four characters in the first section, and then the cursor automatically moves to the next section.
The same thing that I want in my application.
To do this, first add CustomizedTextFields.jar and then create four IntegerField:
private IntegerField text1; private IntegerField text2; private IntegerField text3; private IntegerField text4;
after that I show all these IntegerField on my frame.
Now I tried this code to send the cursor to the following field, but it does not work:
text1.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { int a2 = text1.getText().length(); if (a2 == 3) { text2.getCursor(); } } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { } });
Vinit Vikash
source share