免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4789 | 回复: 2
打印 上一主题 下一主题

requestFocusInWindow疑问 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-12-09 17:34 |只看该作者 |倒序浏览
当打开一个窗口的时候,我需要将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.

论坛徽章:
0
2 [报告]
发表于 2005-12-09 18:44 |只看该作者
InputFocus一直都是个大问题。尤其是Java需要在不同的窗口系统中运行,所以很难保证任何情况下都能得到InputFocus。好像没有什么特别好的解决方法

论坛徽章:
0
3 [报告]
发表于 2005-12-12 18:55 |只看该作者

hmmm

多谢斑竹。我再想想办法,看能不能绕过这个问题。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP