e609. Listening to All Focus Changes Between Components in an Application
To listen to focus change events between components, install a listener with the keyboard focus manager. If you need the ability to veto (reject) a focus change, install a vetoable listener with the keyboard focus manager.
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addPropertyChangeListener(new FocusChangeListener());
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addVetoableChangeListener(new FocusVetoableChangeListener()); class FocusChangeListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent evt) {
Component oldComp = (Component)evt.getOldValue();
Component newComp = (Component)evt.getNewValue(); if ("focusOwner".equals(evt.getPropertyName())) {
if (oldComp == null) {
// the newComp component gained the focus
} else {
// the oldComp component lost the focus
}
} else if ("focusedWindow".equals(evt.getPropertyName())) {
if (oldComp == null) {
// the newComp window gained the focus
} else {
// the oldComp window lost the focus
}
}
}
} class FocusVetoableChangeListener implements VetoableChangeListener {
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
Component oldComp = (Component)evt.getOldValue();
Component newComp = (Component)evt.getNewValue(); if ("focusOwner".equals(evt.getPropertyName())) {
if (oldComp == null) {
// the newComp component will gain the focus
} else {
// the oldComp component will lose the focus
}
} else if ("focusedWindow".equals(evt.getPropertyName())) {
if (oldComp == null) {
// the newComp window will gain the focus
} else {
// the oldComp window will lose the focus
}
} boolean vetoFocusChange = false;
if (vetoFocusChange) {
throw new PropertyVetoException("message", evt);
}
}
| Related Examples |
e609. Listening to All Focus Changes Between Components in an Application的更多相关文章
- e611. Setting Focus Traversal Keys for the Entire Application
This example changes the focus traversal keys for the entire application. For an example of how to c ...
- ssemble JavaBeans components into an application without having to write any code
https://docs.oracle.com/javase/tutorial/javabeans/ https://docs.oracle.com/javase/tutorial/javabeans ...
- 5.7 Components — Sending Actions From Components to Your Application
一.概述 1. 当一个组件在模板中被使用时,它具有发送action到这个模板的controller和routes的能力.当重大事件发生的时候,这些允许组件通知application,比如点击组件一个特 ...
- e606. Determining Which Component or Window Has the Focus
// null is returned if none of the components in this application has the focus Component compFocusO ...
- ExtJS笔记5 Components
参考 :http://blog.csdn.net/zhangxin09/article/details/6914882 An Ext JS application's UI is made up of ...
- Android ANR Waiting because no window has focus问题分析
转自:https://www.cnblogs.com/MMLoveMeMM/articles/4849667.html 这种问题主要是发生在两个应用页面之间切换的时候,这个临界点的时候,一个页面正在起 ...
- 5、二、App Components(应用程序组件):0、概述
二.App Components(应用程序组件) 0.概述 App Components Android's application framework lets you create rich ...
- e610. Setting Focus Traversal Keys in a Component
When the focus is on a component, any focus traversal keys set for that component override the defau ...
- [Vue] Load components when needed with Vue async components
In large applications, dividing the application into smaller chunks is often times necessary. In thi ...
随机推荐
- .NET MVC EF框架数据库连接配置
1:数据库的配置和连接 Web.config <connectionStrings> <add name="SQLConnectionString" connec ...
- c#,asp.net 开发 app 学习资料整理
VS2015 Apache Cordova第一个Android和IOS应用 http://www.cnblogs.com/aehyok/p/4116410.html PhoneGap:免费开源的 HT ...
- chorme插件 ,在浏览器上模拟手机,pad 查看网页|前端技术开发必备插件
网址:http://lab.maltewassermann.com/viewport-resizer/使用方法:1在chrome浏览器上方右击,显示书签栏 2 打开插件网址,将<ignore_j ...
- lua的模块加载require
加载指定的模块.首先函数会在 package.loaded 这个表中查看是否已经加载 了 modname 这个模块.如果是,那么 require 会返回保存在 package.loaded[modna ...
- 2017-04-26 ios ipv6那些事(已完美解决)
2017-04-26 ios ipv6那些事(已完美解决) 工作单位性质属于外包公司,每天都有几十的app要提交上传至应用市场,于2017年3月份接到ios工程师反馈 Guideline 2.1 ...
- Quo JS多种触摸手势轻量级JavaScript库
http://www.uedsc.com/quo-js.html http://quojs.tapquo.com/
- LeetCode: Search in Rotated Sorted Array 解题报告
Search in Rotated Sorted Array Suppose a sorted array is rotated at some pivot unknown to you before ...
- keepalived+nginx双机热备+负载均衡
Reference: http://blog.csdn.net/e421083458/article/details/30092795 keepalived+nginx双机热备+负载均衡 最近因业务扩 ...
- CSS网页布局中易犯的30个小错误
即使是CSS高手,也难免在书写CSS代码的时候出一些小错误,或者说,任何一种代码都是如此.小错误却往往造成大问题,浪费很多无辜的时间来调试和排错.查看下面这份CSS网页布局中易犯的10个小错误,努力的 ...
- 基于jQuery点击图像居中放大插件Zoom
分享一款基于jQuery点击图像居中放大插件Zoom是一款放大的时候会从原图像的位置以动画方式放大到画面中间,支持点击图像或者按ESC键来关闭效果.效果图如下: 在线预览 源码下载 实现的代码. ...