Java Reference
In-Depth Information
23. }
24.
25. public void setHireDate(GregorianCalendar hd) {
26. hireDate = hd;
27. }
28.
29. public void setFullTime(boolean fullTime) {
30. this.fullTime = fullTime;
31. }
32.
33. public boolean isFullTime() {
34. return fullTime;
35. }
36.}
Read and Write JavaBeans Properties
A class does not need to contain matching set and get methods for each property. A read-only
property would only have a get method and a write-only property would only have a set method.
I should also point out that the names of the fi elds in a class have nothing to do with
JavaBean properties. For example, line 6 of the Employee class declares a public fi eld
named salary , but salary is not a JavaBean property of the Employee class.
Here are the JavaBean properties that the Employee class does have:
firstName : A read-only String property
lastName : A String property
hireDate : A GregorianCalendar property
fullTime : A boolean property
JavaBean Event Methods
The JavaBean specifi cation also defi nes event handler methods that have the
following naming convention:
public void addXxxxListener(XxxxListener a)
public void removeXxxxListener(XxxxListener a)
Search WWH ::




Custom Search