如何找出哪个对象当前有焦点 [英] How to find out which object currently has focus

查看:87
本文介绍了如何找出哪个对象当前有焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Frame 中有几个 TextField 。我想知道哪个 TextField 目前有焦点。如何找到这个信息?

解决方案

JFrame.getFocusOwner() (继承自 Window.getFocusOwner() )应该返回一个对焦点组件的引用。 getMostRecentFocusOwner()也可能是有趣的。


I have a few TextFields in my Frame. I want to know which TextField currently has focus. How can I find this information?

解决方案

JFrame.getFocusOwner() (inherited from Window.getFocusOwner()) ought to return a reference to the component with focus. getMostRecentFocusOwner() might also be of interest.

这篇关于如何找出哪个对象当前有焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆