Java tutorial
import javax.swing.JTextField; import javax.swing.SwingUtilities; public class Main { public static void main(String[] argv) throws Exception { final JTextField textfield = new JTextField(10); SwingUtilities.invokeLater(new Runnable() { public void run() { textfield.requestFocus(); } }); } }