본문 바로가기

WebStudy/JAVA SWING

창이 생성되면 바로 JTextField에 focus (포커스) 주기

If you want your JTextField to be focused when your GUI shows up, you can use this:

in = new JTextField(40);
f.addWindowListener( new WindowAdapter() {
    public void windowOpened( WindowEvent e ){
        in.requestFocus();
    }
}); 

Where f would be your JFrame and in is your JTextField.

 

출처 : 스택오버플로우