- 论坛徽章:
- 0
|
当打开一个窗口的时候,我需要将focus设定在某个TextField上。我用的是requestFocusInWindow。但是通过测试发现,多次打开和关闭窗口,有时候focus能正常的设定在我期待的field上,但是有些时候就不可以。为什么会这样呢?我查看了JDK文档,有如下一段话,难道就是说这个问题?有什么解决办法吗?
Requests that this Component get the input focus, if this Component's top-level ancestor is already the focused Window. This component must be displayable, visible, and focusable for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this component is the focus owner until this component receives a FOCUS_GAINED event. |
|