Java Observer Template Does Not Notify

For some reason, my watchers are not notified when I call the notifyObserver methods using java.util.Observable objects:

here is my observable object:

public class ProjectManager extends Observable
{
...
 public void updateProjects(String project, String pack, String source, String ARN)
{
   ...
if(newSource)
    {
    tempPack.add(tempSource);
    System.out.println("Notify observers: " + this.countObservers());
    this.notifyObservers();
    }
      ...
      }

I can see from my conclusion that the observer is being added, but not notified.

and my observer object looks like this:

public class IDE implements Observer
{

@Override
public void update(Observable o, Object arg) {

    System.out.println("Notified");

}

For some strange reason, the observed object is not notified at all. Am I something wrong here?

+5
source share
1 answer

You need setChangedbefore younotifyObservers

+13
source

All Articles