The opposite component is the other component affected in a focus event. Specifically, in a focus-lost event, the opposite component is the one gaining the focus. In a focus-gain event, the opposite component is the one losing the focus.

Sometimes the opposite component is null, which indicates that the component is in some other application.

component.addFocusListener(new MyFocusListener());

    public class MyFocusListener extends FocusAdapter {
public void focusGained(FocusEvent evt) {
// The component that lost the focus
Component c = evt.getOppositeComponent();
} public void focusLost(FocusEvent evt) {
// The component that gained the focus
Component c = evt.getOppositeComponent();
}
}
Related Examples

e617. Determining the Opposite Component of a Focus Event的更多相关文章

  1. [HTML5] Using the focus event to improve navigation accessibility (nextElementSibling)

    For a menu item, when we tab onto it, we want this element get 'focus' event, so that the submenu wi ...

  2. 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 ...

  3. e620. Activating a Keystroke When Any Component in the Window Has Focus

    Normally, a keystroke registered to a component is activated when the component has the focus. This ...

  4. e616. Determining If a Focus Lost Is Temporary or Permanent

    A temporary focus-lost event occurs if the focus moves to another window. It's temporary because the ...

  5. e621. Activating a Keystroke When Any Child Component Has Focus

    Normally, a keystroke registered on a component is activated when the component has the focus. This ...

  6. e614. Setting the Initial Focused Component in a Window

    There is no straightforward way to set the initial focused component in a window. The typical method ...

  7. 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 mana ...

  8. e615. Finding the Next Focusable Component

    public Component findNextFocus() { // Find focus owner Component c = KeyboardFocusManager.getCurrent ...

  9. salesforce lightning零基础学习(四) 事件(component events)简单介绍

    lightning component基于事件驱动模型来处理用户界面的交互.这种事件驱动模型和js的事件驱动模型也很相似,可以简单的理解成四部分: 1.事件源:产生事件的地方,可以是页面中的输入框,按 ...

随机推荐

  1. latex基本语法

    一直想着学会latex,但是自学起来太麻烦,总是出现各种不理解的错误,也没那么多时间钻研,就学了忘,忘了再学,这里就先摘录下它的基本命令吧.学好了是一件利器!(虽然不常用,但要尽量学会) LaTex基 ...

  2. 【嵌入式】使用Cross Toolchain构建交叉工具链

    Preface 前面编译linux内核的时候,用各种cross版本都不行啊,真是纠结,于是就想着自己也要会编译交叉工具的方法,然后各种尝试,各种问题啊,最后还是没解决(还有其它事情),步骤我都走熟了, ...

  3. 【Cmd】那些年,我们迷恋的cmd命令(二)

    那些年,我们迷恋的命令(一) 那些年,我们迷恋的命令(二) Linux系统下基本命令 Linux系统下基本命令: 要区分大小写 uname 显示版本信息(同win2K的 ver) dir 显示当前目录 ...

  4. Mac系统安装Lua

    1.下载最新版的lua-5.2.3 请点击,然后解压 2. 运行“终端”进入到该文件夹下,主要是cd [文件夹名] 3.在“终端”输入    make macosx   (回车) 4.在“终端”输入  ...

  5. 修改urllib2源代码,定制User-Agent,一劳永逸

    我经常用到urllib2这个库,基本上每次都要添加 User-Agent 为一个模拟浏览器的值. 突然想到,能不能直接修改源代码,添加 User-Agent 的值. google 到 https:// ...

  6. phpmyadmin 各种技巧拿 webshell

    site.com/phpMyAdminsite.com/sql D:\wamp\www 账号还有密码 root 密码第一种CREATE TABLE `mysql`.`darkmoon` (`darkm ...

  7. Git CMD连接,管理(remote,add,commit,push)github repository

    git initmd testcd testgit statusgit add test  //git add test/a.txtgit status git remote add origin g ...

  8. Android基础——使用Fragment适应不同屏幕和分辨率

    最近事情很忙,一个新项目赶着出来,但是很多功能都要重新做,一直在编写代码.Debug.今天因为一个新程序要使用Fragment来做,虽然以前也使用过Fragment,不过没有仔细研究,今天顺道写篇文章 ...

  9. Android 面试知识集1

    今晚在复习Android基础的时候,找到了一些很有价值的基础知识,分享给给位Android的开发者.这些是基础知识,同时也可以当做面试准备.面试题其实是很好的基础知识学习,有空会好好整理相关基础知识. ...

  10. ViewController之间的转场和数据传递

    ViewController之间的转场和数据传递 可以正向传递值, 反向传递值. 注意反向传值的时候,方法的位置: https://github.com/urmyfaith/GRDBUsage/blo ...