
friends... good day.. i have doubt in java gui. ? i created 1 java gui application. That has two text fields jtext1,jtext2. case: user entered value in first textfield(jtext1) and pressed the enter key . the cursor must go to the next text field(jtext2). How can i arrange this. which code can i use from the action listener of jtext1 to happen like this.

import java.awt.*;
import javax.swing.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
class JavaGUI{
public static void main(String[] args){
JFrame f=new JFrame();
JTextField text1=new JTextField(20);
final JTextField text2=new JTextField(20);
text1.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if( e.getKeyCode() == KeyEvent.VK_ENTER ){
text2.requestFocus();
}
}
});
JPanel p=new JPanel(new GridLayout(2,1));
p.add(text1);
p.add(text2);
f.add(p);
f.setVisible(true);
f.pack();
}
}

ya...very vry thanx dude.... its very helpful 2 me....

KeyEvent.VK_ENTER is for getting enterkey. then how can get other keys...?
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.