MyModel.java Source code

Java tutorial

Introduction

Here is the source code for MyModel.java

Source

import java.util.Observable;
import java.util.Observer;

class MyModel extends Observable {
    public synchronized void setChanged() {
        super.setChanged();
    }
}

public class Main {
    public static void main(String[] argv) throws Exception {
        MyModel model = new MyModel();
        model.addObserver(new Observer() {
            public void update(Observable o, Object arg) {
            }
        });
        model.setChanged();
        Object arg = "new information";
        model.notifyObservers(arg);
    }
}