Java Reference
In-Depth Information
102. case 4: value = data[row].getEndDate();
103. break;
104. }
105. return value;
106. }
107. public boolean isCellEditable(int row, int column){
108. return ((column == 0) || (column == 2)) ? true : false;
109. }
110. public void setValueAt(Object value, int row, int column){
111. switch(column){
112. case 0: data[row].setReason((String)value);
113. editor.edit();
114. break;
115. case 1:
116. break;
117. case 2: data[row].setLocation(new LocationImpl((String)value));
118. editor.edit();
119. break;
120. case 3:
121. break;
122. case 4:
123. break;
124. }
125. }
126. }
127. }
Five business support classes and interfaces are used in this example: Appointment , Contact , ContactImpl ,
Location , and LocationImpl .
Example A.100 Appointment.java
1. import java.io.Serializable;
2. import java.util.Date;
3. import java.util.ArrayList;
4. public class Appointment implements Serializable{
5. private String reason;
6. private ArrayList contacts;
7. private Location location;
8. private Date startDate;
9. private Date endDate;
10.
11. public Appointment(String reason, ArrayList contacts, Location location, Date startDate,
Date endDate){
12. this.reason = reason;
13. this.contacts = contacts;
14. this.location = location;
15. this.startDate = startDate;
16. this.endDate = endDate;
17. }
18.
19. public String getReason(){return reason;}
20. public ArrayList getContacts(){return contacts;}
21. public Location getLocation(){return location;}
22. public Date getStartDate(){return startDate;}
23. public Date getEndDate(){return endDate;}
24.
25. public void setReason(String reason){this.reason = reason;}
26. public void setContacts(ArrayList contacts){this.contacts = contacts;}
27. public void setLocation(Location location){this.location = location;}
28. public void setStartDate(Date startDate){this.startDate = startDate;}
29. public void setEndDate(Date endDate){this.endDate = endDate;}
30.
31. public String toString(){
32. return “Appointment:” + "\n Reason:” + reason +
33. "\n Location: ” + location + "\n Start:” +
34. startDate + "\n End:” + endDate + "\n”;
35. }
36. }
Example A.101 Contact.java
1. import java.io.Serializable;
2. public interface Contact extends Serializable{
3. public static final String SPACE = " ";
4. public String getFirstName();
5. public String getLastName();
6. public String getTitle();
Search WWH ::




Custom Search