检测挥杆中(框架+组件)的焦点 [英] Detecting Focus on (frame + components) in swing

查看:147
本文介绍了检测挥杆中(框架+组件)的焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的对话框出现,在这个框架内有一系列的按钮和一个文本框。
我需要框架能够检测到用户何时把焦点放在屏幕上的其他东西上(除了框架及其组件外的任何东西),所以我可以关闭框架。
有关如何解决这个问题的任何建议?

解决方案


需要框架以便能够检测用户何时将焦点放在屏幕上的其他内容上。

使用WindowListener并侦听windowDeactivated。 p>

I have a small dialog frame that appears, and within this frame are a series of buttons and a textbox. I need the frame to be able to detect when the user has put focus on something else on the screen (being: anything besides the frame and its components), so I can close down the frame. Any advice on how to go about this? I've been trying at focus solutions for hours, to no solution!

解决方案

need the frame to be able to detect when the user has put focus on something else on the screen

Use a WindowListener and listen for windowDeactivated.

这篇关于检测挥杆中(框架+组件)的焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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