Escolar Documentos
Profissional Documentos
Cultura Documentos
behavior of a bean
Support for events
Allowing beans to communicate
Bound
Constrained
For any property named P of type T the get and set methods has the
following syntax
1.Simple Properties public T getP()
public void setP ( T value)
Here type can be integer or string
2.Boolean Properties public boolean isP()
public void setP(boolean value)
Here type is boolean
3.Indexed Properties public T[] getP()
public void setP(T[] values)
public T getP(int index)
public void setP(int index,T value)
Here type can be array of another type
Coding examples for Properties
package simpleBean.example;
public class SimpleBean
{
private String name;
private String password;
public String getName(){return name;}
public void setName(String name){ this.name =
name;}
public String getPassword(){return password;}
public void setPassword (String name)
{ this.password = password;}
}
Coding examples for Properties
package simpleBean.example;
public class ArrayBean
{
private String things[ ];
public String[ ] getThings()
{return things;}
public void setThings (String things)
{ this.things = things;}
public String getThings (int i)
{return things[i];}
public void setThings (int i, String things)
{ things[i] = things;}
Events
A bean communicates with other beans by generating
events
Two types of objects are involved:
“Source” objects.
“Listener” objects.
public void
addPropertyChangeListener(
PropertyChangeListener el)
public void removePropertyChangeListener(
PropertyChangeListener el)
Constrained property
When bean tries to set a property to an unacceptable
value it generates or throws a VetoEvent such a
property is said to be constrained property
It is also special event
capable of generating.
MethodDescriptor