2019年1月16日 星期三

swing 的組織想法

// 中間協調者
public class Observeable<T> {
    // 要通知的組件
    public ArrayList<Observe> elements;
   
    public void emit(String eventName, T data){
       
    }
}

public interface Observe<T> {
   
    public void on(String eventName);
   
    public void off(String eventName);
   
    public void notify(String eventName, T data);
}

public class Element<T, E> implements Observe<E> {
    // swing 元件
    public T x;

    @Override
    public void on(String eventName) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void off(String eventName) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void notify(String eventName, E data) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }  
}