登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

学无止境

一点积累,与大家分享

 
 
 

日志

 
 

PropertyChangeEvent   

2010-05-18 13:55:14|  分类: java技术 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
awt 体系结构中Event  局限于该体系,从前章 与 以下Component 代码可以看出 Event 的依赖于Component;

boolean eventTypeEnabled(int type) {
4161        switch(type) {
4162          case ComponentEvent.COMPONENT_MOVED:
4163          case ComponentEvent.COMPONENT_RESIZED:
4164          case ComponentEvent.COMPONENT_SHOWN:
4165          case ComponentEvent.COMPONENT_HIDDEN:
4166              if ((eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ||
4167                  componentListener != null) {
4168                  return true;
4169              }
4170              break;
4171          case FocusEvent.FOCUS_GAINED:
4172          case FocusEvent.FOCUS_LOST:
4173              if ((eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0 ||
4174                  focusListener != null) {
4175                  return true;
4176              }
4177              break;
4178          case KeyEvent.KEY_PRESSED:
4179          case KeyEvent.KEY_RELEASED:
4180          case KeyEvent.KEY_TYPED:
4181              if ((eventMask & AWTEvent.KEY_EVENT_MASK) != 0 ||
4182                  keyListener != null) {
4183                  return true;
4184              }
4185              break;
4186          case MouseEvent.MOUSE_PRESSED:
4187          case MouseEvent.MOUSE_RELEASED:
4188          case MouseEvent.MOUSE_ENTERED:
4189          case MouseEvent.MOUSE_EXITED:
4190          case MouseEvent.MOUSE_CLICKED:
4191              if ((eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0 ||
4192                  mouseListener != null) {
4193                  return true;
4194              }
4195              break;
4196          case MouseEvent.MOUSE_MOVED:
4197          case MouseEvent.MOUSE_DRAGGED:
4198              if ((eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 ||
4199                  mouseMotionListener != null) {
4200                  return true;
4201              }
4202              break;
4203          case MouseEvent.MOUSE_WHEEL:
4204              if ((eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0 ||
4205                  mouseWheelListener != null) {
4206                  return true;
4207              }
4208              break;
4209          case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
4210          case InputMethodEvent.CARET_POSITION_CHANGED:
4211              if ((eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 ||
4212                  inputMethodListener != null) {
4213                  return true;
4214              }
4215              break;
4216          case HierarchyEvent.HIERARCHY_CHANGED:
4217              if ((eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 ||
4218                  hierarchyListener != null) {
4219                  return true;
4220              }
4221              break;
4222          case HierarchyEvent.ANCESTOR_MOVED:
4223          case HierarchyEvent.ANCESTOR_RESIZED:
4224              if ((eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 ||
4225                  hierarchyBoundsListener != null) {
4226                  return true;
4227              }
4228              break;
4229          case ActionEvent.ACTION_PERFORMED:
4230              if ((eventMask & AWTEvent.ACTION_EVENT_MASK) != 0) {
4231                  return true;
4232              }
4233              break;
4234          case TextEvent.TEXT_VALUE_CHANGED:
4235              if ((eventMask & AWTEvent.TEXT_EVENT_MASK) != 0) {
4236                  return true;
4237              }
4238              break;
4239          case ItemEvent.ITEM_STATE_CHANGED:
4240              if ((eventMask & AWTEvent.ITEM_EVENT_MASK) != 0) {
4241                  return true;
4242              }
4243              break;
4244          case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
4245              if ((eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0) {
4246                  return true;
4247              }
4248              break;
4249          default:
4250              break;
4251        }
在我们自定义应用程序中,常用的继承底层类来实现业务;
PropertyChangeEvent 是基于底层类,通过继承或直接使用它 来实现customerEvent;
from:http://kickjava.com/src/java/beans/PropertyChangeEvent.java.htm
/*
2  * @(#)PropertyChangeEvent.java 1.33 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.beans;
9
10 /**
11  * A "PropertyChange" event gets delivered whenever a bean changes a "bound"
12  * or "constrained" property. A PropertyChangeEvent object is sent as an
13  * argument to the PropertyChangeListener and VetoableChangeListener methods.
14  * <P>
15  * Normally PropertyChangeEvents are accompanied by the name and the old
16  * and new value of the changed property. If the new value is a primitive
17  * type (such as int or boolean) it must be wrapped as the
18  * corresponding java.lang.* Object type (such as Integer or Boolean).
19  * <P>
20  * Null values may be provided for the old and the new values if their
21  * true values are not known.
22  * <P>
23  * An event source may send a null object as the name to indicate that an
24  * arbitrary set of if its properties have changed. In this case the
25  * old and new values should also be null.
26  */

27
28 public class PropertyChangeEvent extends java.util.EventObject JavaDoc {
29
30     /**
31      * Constructs a new <code>PropertyChangeEvent</code>.
32      *
33      * @param source The bean that fired the event.
34      * @param propertyName The programmatic name of the property
35      * that was changed.
36      * @param oldValue The old value of the property.
37      * @param newValue The new value of the property.
38      */

39     public PropertyChangeEvent(Object JavaDoc source, String JavaDoc propertyName,
40                      Object JavaDoc oldValue, Object JavaDoc newValue) {
41     super(source);
42     this.propertyName = propertyName;
43     this.newValue = newValue;
44     this.oldValue = oldValue;
45     }
46
47     /**
48      * Gets the programmatic name of the property that was changed.
49      *
50      * @return The programmatic name of the property that was changed.
51      * May be null if multiple properties have changed.
52      */

53     public String JavaDoc getPropertyName() {
54     return propertyName;
55     }
56     
57     /**
58      * Sets the new value for the property, expressed as an Object.
59      *
60      * @return The new value for the property, expressed as an Object.
61      * May be null if multiple properties have changed.
62      */

63     public Object JavaDoc getNewValue() {
64     return newValue;
65     }
66
67     /**
68      * Gets the old value for the property, expressed as an Object.
69      *
70      * @return The old value for the property, expressed as an Object.
71      * May be null if multiple properties have changed.
72      */

73     public Object JavaDoc getOldValue() {
74     return oldValue;
75     }
76
77     /**
78      * Sets the propagationId object for the event.
79      *
80      * @param propagationId The propagationId object for the event.
81      */

82     public void setPropagationId(Object JavaDoc propagationId) {
83     this.propagationId = propagationId;
84     }
85
86     /**
87      * The "propagationId" field is reserved for future use. In Beans 1.0
88      * the sole requirement is that if a listener catches a PropertyChangeEvent
89      * and then fires a PropertyChangeEvent of its own, then it should
90      * make sure that it propagates the propagationId field from its
91      * incoming event to its outgoing event.
92      *
93      * @return the propagationId object associated with a bound/constrained
94      * property update.
95      */

96     public Object JavaDoc getPropagationId() {
97     return propagationId;
98     }
99
100     /**
101      * name of the property that changed. May be null, if not known.
102      * @serial
103      */

104     private String JavaDoc propertyName;
105
106     /**
107      * New value for property. May be null if not known.
108      * @serial
109      */

110     private Object JavaDoc newValue;
111
112     /**
113      * Previous value for property. May be null if not known.
114      * @serial
115      */

116     private Object JavaDoc oldValue;
117
118     /**
119      * Propagation ID. May be null.
120      * @serial
121      * @see #getPropagationId.
122      */

123     private Object JavaDoc propagationId;
124 }

  评论这张
 
阅读(932)| 评论(0)

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018