This topic given documentation elements for fr.jmmc.mcs.util package

ObservableDelegate

This object can be used by one class that must extend one mother class and be observed. It can be Observable using one delegate class. See java.util.Observer/Observable classes and interface.

Code snippet.


public Class A implements Observer{
  public void update(Observable o, Object arg){
    if(o instanceof ObservableDelegate){
        Object source = ((ObservableDelegate)o).getSource();
    }
    //add code
 }
}

public Class B {
  ObservableDelegate delegate;
  public B(){
    delegate = ObservableDelegate(this);
  }

  public void addObserver(Observer o){
    delegate.addObserver(Observer o);
  }
}


This topic: Jmmc/Software > WebHome > JMCS > JMCSFrJmmcMcsUtil
Topic revision: r1 - 2009-03-04 - GuillaumeMella
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback