I got the solution but its crude one. Would be great to find alternatives.
This is from one of the java tips and tricks site
http://privat.schlund.de/b/bossung/prog/java/tips.html Problem: Initially giving the focus to a specified component in the dialog.
Version: Swing 1.x
Suggested Solution: Swing will initially give the focus to the first component you add to the dialog. Thus you can just add the desired component first. If that does not work for you it seems you have to go through major pain.
There is of course a method in each component that requests the focus (therefore called requestFocus()) which works fine. However, if you call it during your initializing operations, Swing will late give the focus back to the first component you added. The only way around this, which I found working more than one system, is to write a class that will focus a component about 0.5 seconds after it is initialized:
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
public class FocusSetter implements ActionListener {
private JComponent component;
private javax.swing.Timer timer;
public FocusSetter(JComponent comp) {
this.component = comp;
this.timer = new javax.swing.Timer(500, this);
this.timer.start();
}
public void actionPerformed(ActionEvent evt) {
if ((evt != null) && (evt.getSource() == timer)) {
component.requestFocus();
}
}
}