글쓴이 :해 효 1998년 6월 12일 18:55:48
희정님께 감사드리며...하나더..
이벤트와 다른부분들이 많이 바꿔었다고 하셨는데,
제가 참고로하는 2종류의 책은 모두 1.0 대 이군요.
웹상이나,아니면,어디를 참고하면 새로워진 1.1 대
함수, 명령어 부분들을 배울수 있나요....
그리고 희정님 얘기처럼 에러나는 부분을 //하고
컴파일한후 브라우저에서 불러보면은 프레임창은
뜨지 않고 에러가 나는군요. 음...
그리고, 맨 밑에 e.getSource 는 어떤 역할을 하나요.
왜 쓰인거죠..
감사....좋은 저녁....
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Gui3 extends java.applet.Applet implements ActionListener {
Frame window;
public void init() {
window = new MyFrame("A PopUp Window");
window.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
window.setSize(400, 300);
window.setVisible(true);
}
class MyFrame extends Frame {
MyFrame(String title) {
super(title);
Panel p = new Panel();
p.setLayout(new FlowLayout());
Button cancel = new Button("Cancel");
// cancel.addActionListener(this);
// 이부분에 어떤 객체를 넘겨야 하는지 모르겠네요...^^;
// 어플리케이션이랑 많이 다른가?
// D:\JAVA\java_src\Gui2.java:35: Incompatible type for method.
// Explicit cast needed to convert Gui2. MyFrame to
// java.awt.event.ActionListener.
// cancel.addActionListener(this);
// ^
// 1 error
// 하옇든, 이 부분은 다른 분의 도움을 받으시죠...^^;
// 죄송합니다. 저도 공부한지가 얼마되지 않아서리...^^;
p.add(cancel);
add("South", p);
p.add(new Label("This is a Window",Label.CENTER));
}
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() instanceof Button) {
String label = ((Button)e.getSource()).getLabel();
if (label == "Cancel") {
System.exit(0);
}
}
}
}