public class EventTest2 extends Frame {
Button btn;
public EventTest2() {
setTitle("버튼 클릭쿨릭");
setLayout(new FlowLayout());
btn = new Button("버튼액션");
add(btn);
setSize(300, 300);
setVisible(true);
A a = new A(this);
// this <--EventTest2를 다 가져오겠어
btn.addActionListener(a);
// 메소드호출: method(데이터)
// 생성자호출: new A( 203호 )
}
public static void main(String[] args) {
new EventTest2(); // 203호
}
}
public class A implements ActionListener {
Frame f;
EventTest2 event2;
public A(Frame f) {
// EventTest2 f=new EventTest2();
// Frame f= new EventTest2(); <--자식이니까
System.out.println(f);
this.f = f;
}
@Override
public void actionPerformed(ActionEvent e) {
f.setTitle("변경");
// =EventTest2.setTitle();
}
}