Chinaunix

标题: 关于获TextField取焦点[求助] [打印本页]

作者: scwfeng    时间: 2006-04-06 18:07
标题: 关于获TextField取焦点[求助]
在窗口中,切换到一个新界面后,怎么样使其中某个TextField获得焦点,并且将光标移入其中,仅仅使用setFocusable()函数好像还不够!请问应怎么办?
作者: kakasi    时间: 2006-04-06 18:40
txt.requestFocusInWindow()
作者: 白色乌鸦    时间: 2006-04-06 18:41
from jdk 1.4.0 help documentation


  1. requestFocus
  2. public void requestFocus()
  3. Requests that this Component get the input focus, and that this Component's top-level ancestor become 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. If this request is denied because this Component's top-level Window cannot become the focused Window, the request will be remembered and will be granted when the Window is later focused by the user.
  4. This method cannot be used to set the focus owner to no Component at all. Use KeyboardFocusManager.clearGlobalFocusOwner() instead.

  5. Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use requestFocusInWindow when possible.
复制代码

作者: scwfeng    时间: 2006-04-06 18:44
谢谢!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2