02 관찰자 모드 - Awt 시뮬레이션(2)
1948 단어 관찰자 모드
public static void main(String[] args) {
Buttton b = new Buttton();
b.addActionListener(new MyActionListener());
b.addActionListener(new MyActionListener2());
b.buttonPressed();
}
}
/**
*
* @author Administrator
*
*/
class Buttton{
List<ActionListener> actionListeners = new ArrayList<ActionListener>();
public void buttonPressed(){
ActionEvent actionEvent = new ActionEvent(System.currentTimeMillis(),this);
for(ActionListener al : actionListeners){
al.actionPerformed(actionEvent);
}
}
public void addActionListener(ActionListener actionListener){
actionListeners.add(actionListener);
}
}
/**
*
* @author Administrator
*
*/
interface ActionListener{
public void actionPerformed(ActionEvent actionEvent);
}
class MyActionListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent actionEvent) {
System.out.println("actionPerformed 1.....");
}
}
class MyActionListener2 implements ActionListener{
@Override
public void actionPerformed(ActionEvent actionEvent) {
System.out.println("actionPerformed 2.....");
}
}
class ActionEvent{
//
long when;
//
Object source;
public ActionEvent(long when,Object source) {
this.source = source;
this.when = when;
}
public long getWhen(){
return when;
}
public Object getSource(){
return source;
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
관찰자 모드를 JavaScript로 구현하는 방법관찰자 모델은 발표-구독 모델이라고도 불리며 디자인 모델 중의 행위형 모델이다. 그래야만 아이폰11이 도착했다는 것을 제때에 알 수 있기 때문에 모든 구독 행위의 구체적인 방법이 필요합니다. 이미 핸드폰이 있기 때문...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.