글쓴이 :윤경구 1998년 6월 13일 10:02:53
In Reply to: [질문] 경구님... 답변 부탁드립니다. posted by 이희정 on 1998년 6월 12일 20:24:50:
JDK 1.1 버전으로 바꾸면 다음과 같이 됩니다.
// Gui2.java
import java.awt.*;
import java.awt.event.*;
public class Gui2 extends java.applet.Applet {
Frame window;
public void init() {
window = new MyFrame("A PopUp Window");
window.setSize(400, 300);
window.setVisible(true);
}
}
class MyFrame extends Frame
implements ActionListener {
MyFrame(String title) {
super(title);
Panel p = new Panel();
p.setLayout(new FlowLayout());
Button button= new Button("cancel");
button.addActionListener(this);
p.add(button);
add(p, "South");
p.add(new Label("This is a Window",Label.CENTER));
addWindowListener(
new WindowAdapter() { // anonymous local class
public void windowClosing(WindowEvent we) {
setVisible(false);
dispose();
}
}
);
}
// button action handler
public void actionPerformed(ActionEvent action) {
Object source=action.getSource();
if (source instanceof Button
&& action.getActionCommand().equals("cancel"))
{
setVisible(false);
dispose();
}
}
}