
Sample Code
File : FrameEvent
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class FrameEvent extends Frame implements WindowListener {
public FrameEvent( ) {
setLayout(new GridLayout(2, 4));
// setLayout(new GridLayout(4, 2));
add(new Button("버튼 1")); add(new Button("버튼 2"));
add(new Button("버튼 3")); add(new Button("버튼 4"));
add(new Button("버튼 5")); add(new Button("버튼 6"));
add(new Button("버튼 7")); add(new Button("버튼 8"));
// setLayout(new BorderLayout( ));
// add(new Button("버튼 1"), BorderLayout.EAST);
// add(new Button("버튼 2"), BorderLayout.WEST);
// add(new Button("버튼 3"), BorderLayout.SOUTH);
// add(new Button("버튼 4"), BorderLayout.NORTH);
// add(new Button("버튼 5"), BorderLayout.CENTER);
setSize(300,200);
setVisible(true);
addWindowListener(this);
}
public void windowActivated(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
public void windowDeactivated(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
}
File : Ch17Ex05
public class Ch17Ex05 {
public static void main(String[] args) {
FrameEvent f=new FrameEvent();
}
}
Reference book 이클립스로 배우는 Java 6 Programming/ 임종권, 전병찬/ 가메출판사
댓글 없음:
댓글 쓰기