Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestFocus doesn't work?

 
Zee Ho
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers, I want to let second component of the JFrame to be focused, but seems the requestFocus didn't work, my first component is the combobox, it gains the focus automatically, why I can not move the focus to the specific component
 
Barry Andrews
Ranch Hand
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of Component is it? By default, some Components are not focusable, like labels, panes, etc. starting with Java 1.4. Also if the Component is not displayable, enabled, etc. it will not be focusable. If this does not help, try posting a snippet of code.
 
Zee Ho
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In the UIUtils I just do very simple things to set some attribute to the
JTextField


[ April 09, 2005: Message edited by: Zee Ho ]
 
Zee Ho
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I request the focus on criteria_name which is a JTextField, but weird. it never gain it.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you were given the answer here
>Also if the Component is not displayable, enabled, etc. it will not be focusable.

here's a compilable version of your code, to demonstrate


 
Zee Ho
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reslovced, thx
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic