import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport; public class DemoBeans { private String demoName;
private String Version;
PropertyChangeSupport listeners = new PropertyChangeSupport(this); public DemoBeans() {
demoName = "initValue";
Version="v1000";
} public String getDemoName() {
return demoName;
} public void setDemoName(String demoName) {
String oldValue = this.demoName;
this.demoName = demoName;
//发布监听事件
firePropertyChange("demoName", oldValue, demoName); } public void setDemoVersion(String demoVersion) {
String oldVersion = this.Version;
this.Version = demoVersion;
//发布监听事件
firePropertyChange("demoVersion", oldVersion, demoVersion); }
public void addPropertyChangeListener(PropertyChangeListener listener) {
listeners.addPropertyChangeListener(listener);
} public void removePropertyChangeListener(PropertyChangeListener listener){
listeners.addPropertyChangeListener(listener);
} /**
* 触发属性改变的事件
*/
protected void firePropertyChange(String prop, Object oldValue, Object newValue) {
listeners.firePropertyChange(prop, oldValue, newValue);
}
public static void main(String[] args) {
DemoBeans beans = new DemoBeans(); beans.addPropertyChangeListener(
new PropertyChangeListener(){
public void propertyChange(PropertyChangeEvent evt) {
if(evt.getPropertyName().equals("demoVersion")){
System.out.println("version_OldValue:"+evt.getOldValue());
System.out.println("version_NewValue:"+evt.getNewValue());
System.out.println("version_tPropertyName:"+evt.getPropertyName());
}
else
{
System.out.println("name_OldValue:"+evt.getOldValue());
System.out.println("name_NewValue:"+evt.getNewValue());
System.out.println("name_tPropertyName:"+evt.getPropertyName());
} }}); beans.setDemoName("test");
beans.setDemoVersion("v2000"); }
}

java.beans.PropertyChangeListener的更多相关文章

  1. java beans

    There are N little kids sitting in a circle, each of them are carrying some java beans in their hand ...

  2. [ACM_水题] ZOJ 3714 [Java Beans 环中连续m个数最大值]

    There are N little kids sitting in a circle, each of them are carrying some java beans in their hand ...

  3. java.lang.ClassCastException: sun.jdbc.odbc.JdbcOdbcStatement cannot be cast to java.beans.Statement

    当导入的包为:import java.sql.Statement;时,无任何错误 当导入的包为:import java.beans.Statement;时,出错

  4. SQLException: com.mchange.v2.c3p0.ComboPooledDataSource [ java.beans.IntrospectionException: java.lang.reflect.InvocationTargetException [numThreadsAwaitingCheckoutDefaultUser] ] has been closed()

    问题:Could not get JDBC Connection; nested exception is java.sql.SQLException: com.mchange.v2.c3p0.Com ...

  5. ZOJ3714:Java Beans

    There are N little kids sitting in a circle, each of them are carrying some java beans in their hand ...

  6. Freemaker的java.beans.IntrospectionException: type mismatch between read and write methods

    引言:freemaker在特定的spring以及jdk下的问题解决路径. 环境描述 spring 3.1.1, jdk1.8u80, freemake 2.3.19 错误信息描述: 严重: Excep ...

  7. JSP中操作Java Beans

    以下内容引用自http://wiki.jikexueyuan.com/project/jsp/beans.html: JavaBean是在编写Java时专门创建的Java类,根据JavaBean AP ...

  8. Oracle EBS Form Builder使用Java beans创建窗体

    最近有个项目,需要研究一下Oracle的E-Business Sutie(EBS),对于以前没接触此套件的我来说,简直太痛苦了.在网上找了一堆资料,试着进行Form二次开发,也遇到各类奇葩问题.目前遇 ...

  9. 解决java.beans.Introspector导致的内存泄漏

    解决方案: 在WEB.XML 中配置监听器: <listener> <listener-class> org.springframework.web.util.Introspe ...

随机推荐

  1. Linux下库文件的设置 (/usr/bin/ld: cannot find -lxxx 的解决办法)

    在软件编译过程中,经常会碰到类似这样的编译错误: /usr/bin/ld: cannot find -lhdf5 这表示找不到库文件 libhdf5.so,若是其它库文件,则是 cannot find ...

  2. poj3134 Power Calculus IDA*

    好端端的一道搜索题目,,,硬生生的被我弄成了乱搞题,,,枚举当前的maxd,深搜结果,然而想到的剪枝方法都没有太好的效果,,,最后用一个贪心乱搞弄出来了,,, 贪心:每次必用上一次做出来的数字与其他数 ...

  3. Testing for SSL renegotiation

    https://blog.ivanristic.com/2009/12/testing-for-ssl-renegotiation.html

  4. 洛谷——P2863 [USACO06JAN]牛的舞会The Cow Prom

    https://www.luogu.org/problem/show?pid=2863#sub 题目描述 The N (2 <= N <= 10,000) cows are so exci ...

  5. 安装xcode6 beta 后调试出现Unable to boot the iOS Simulator以及编译苹果官方Swift的demo报错failed with exit code 1的解决的方法

    苹果昨天公布新语言Swift(雨燕),须要安装xcode6 以及mac os 系统为10.9以上. (xcode6 beta 可在官方下载.须要登录开发人员账号:mac os 系统直接更新就可以.在此 ...

  6. Axure7.0在OS X Yosemite(10.10)中不能用的问题

    电脑升级到了10.10后发现axure7.0不能使用.解决办法也非常easy,就是又一次下载一个新的axure版本号,下载地址:http://www.axure.com/release-candida ...

  7. 12、NIO、AIO、BIO一

    1.NIO概述 什么是NIO:NIO是New I/O的简称,与旧式的基于流的I/O方式相对,从名字看,他表示新的一套JAVA I/O标准.它是在java1.4中被纳入到JDK中的,并具有以下特性: - ...

  8. IIS Express加入MIME映射

    近期在用Grid Report做Web报表的时候,碰到一件非常挠头的事. 本地用VS2010写的代码,调试的时候Web报表无法显示,用24.248server上VS2013相同仍是无法显示.最后把项目 ...

  9. 双系统给ubuntu增加分区

    http://www.th7.cn/system/lin/201506/106338.shtml http://www.linuxidc.com/Linux/2012-06/61983.htm 因为本 ...

  10. python-网络-udp

    python-网络-udp 标签(空格分隔): python 开发环境:windows Pycharm+python3.* 工具:网络调试助手 UDP[client]-发送数据 from socket ...