Frame¿¡¼­ implements ActionListener ÇÏ´Â °ÍÀ» »©¸Ô¾ú³×¿ä...


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :À±°æ±¸ 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();
}
}
}




´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]