本文主要是介绍【JavaBeans中的属性!】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
JavaBeans的属性与一般Java程序中所指的属性,或者说与所有面向对象的程序设计语言中对象的属性是同一个概念。在程序中的具体体现就是类中的变量。在JavaBeans的设计中,按照属性的不同作用又细分为4类 :
Simple属性,Index属性,Bound属性,与Constrained属性。
1。Simple
2。Index 表示一个数组值。使用域该属性对应的set/get方法可取得数组中的数值。该属性也可一次设置或取得整
个数组的值 eg:








































3。Bound Bound属性是指当该属性的值发生变化时,要通知其他的对象。每次属性的值改变时,这种属性就触发一个PropertyChange事件(在Java中,事件也是一个对象)。事件中封装了属性名、属性的原值、属性的新值。这种事件传递到其他的Beans,至于接收事件的Beans应该作甚么动作,由其自己定义。
4。Constrained JavaBeans的Constrained属性是指当这个属性的值要发生变化时,与这个属性已经建立了某种连接的其他Java对象可否决属性值的改变。Constrained属性的监听者通过抛出VetoException来阻止该属性的改变。
这篇关于【JavaBeans中的属性!】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!