Problems with the OOP
Hi everyone in the forum,
I posted several months ago a question about what some of you helped a lot to understand about interfaces. Now my problem or question is that i have no idea by using the interfaces and events how to implement this:
i have a logical class in whih several String [] are kept. i am trying to send a message to the interface when some values of this arrays change (actually when they are updated) to actualize the screen (a couple of tables). Now the way i am doing it allows me to send that something in the logical has changed but not what exactly has changed. How can it be done using the interface and events?
Many thanks
private Vector<LogicalDataChangeListener> logicalListeners =new Vector<LogicalDataChangeListener>();
publicvoid addLogicalDataChangeListener(LogicalDataChangeListener l){
if (logicalListeners.contains(l)){
return;
}
logicalListeners.add(l);
}
publicvoid removeLogicalDataChangeListener(LogicalDataChangeListener l){
logicalListeners.remove(l);
}
protectedvoid fireLogicalDataChangeListneners(){
Vector tl;
synchronized (this){
tl = (Vector) logicalListeners.clone();
}
if (logicalListeners.size() == 0){
return;
}
LogicalDataChangeEvent event =new LogicalDataChangeEvent(this);
for(int i= 0; i< logicalListeners.size();i++){
LogicalDataChangeListener listener = (LogicalDataChangeListener)tl.elementAt(i);
listener.dataHasChanged(event);
}
}

