import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
public class Test extends JFrame {
JTextField txt=new JTextField (20);
JTextField txt2=new JTextField (10);
JPanel pa=new JPanel();
Test(){
pa.add(txt);
pa.add(txt2);
this.addWindowListener(new WindowAdapter(){
public void windowActivated(WindowEvent e) {
txt2.requestFocusInWindow();
}
});
this.add(pa);
this.setBounds(20, 20, 300, 200);
this.setVisible(true);
}
public static void main(String s[]){
new Test();
}
}