码迷,mamicode.com
首页 > 其他好文 > 详细

e617. Determining the Opposite Component of a Focus Event

时间:2018-09-06 10:50:34      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:some   end   seve   cte   cells   tab   list   cat   focus   

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

标签:some   end   seve   cte   cells   tab   list   cat   focus   

原文地址:https://www.cnblogs.com/borter/p/9596099.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!