Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set focus in a particular component  RSS feed

 
Yog Ananth
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to set focus in a particular component while openings the screen. request focus is helpless for me. I am using some of the screens jpanel and some of them are JInternalFrame.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>request focus is helpless for me.

the components need to be visible before requestFocus() is called
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yog,

Have you try "requestFocusInWindow();"?

Eg:
----------------
jButton1 = new JButton();
...
...
jButton1.requestFocusInWindow();
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!