package ch11;
//AWT윈도우 프로그램밍을 하려면 아래 패키지를 import
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
//나쁜점 : Frame 종속적인 프로그램이 됨.
public class Ch1101 extends Frame
{
//클래스 요소 이해하기 쉬워서 winform배움.
public Ch1101()
{
//컨테이너 : 컴포턴트에 다른 컴포넌트를 포함시킬수 있는 컴포넌트를 건테이너라 부른다.
// TODO 자동 생성된 생성자 스텁
// Frame frame = new Frame();
// //winform 여부..
// frame.setVisible(true);
// //winform 크기조정.
// frame.setBounds(0, 0, 640, 480);
// //제목넣기
// frame.setTitle("윈도우 제목");
// //배경색상 넣
// frame.setBackground(new Color(125,120,150));
//숙제 -- jframe 소유로 처리.. frame클래스로 계승받아 처리하도록.
super();
int x=10, y=10, width=640, height=480;
String title="윈도우 제목";
Color c=new Color(125,120,150);
this.setBounds(x, y, width, height);
this.setTitle(title);
this.setBackground(c);
//null을 지정시 컴포넌트 배치를 절대좌표체계를 따름
setLayout(null);
Button button1 = new Button();
button1.setBounds(100,100,150,200);
button1.setLabel("버튼1");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO 자동 생성된 메소드 스텁
JOptionPane.showMessageDialog(null, "Hello");
}});
add(button1);
//어너미머스 -> 인너 -> ...
//WindowListener() {} : Anonymous class (어너미머스 클래스 = 이름이 없는 클래스)
addWindowListener(new WindowListener() {
public void windowActivated(WindowEvent e) {
// TODO 자동 생성된 메소드 스텁
}
public void windowClosed(WindowEvent e) {
// TODO 자동 생성된 메소드 스텁
}
public void windowClosing(WindowEvent e) {
// TODO 자동 생성된 메소드 스텁
//Frame클래스(상위클래스)의 dispose함수 호출;
dispose();
}
public void windowDeactivated(WindowEvent e) {
// TODO 자동 생성된 메소드 스텁
}
public void windowDeiconified(WindowEvent e) {
// TODO 자동 생성된 메소드 스텁
}
public void windowIconified(WindowEvent e) {
// TODO 자동 생성된 메소드 스텁
}
public void windowOpened(WindowEvent e) {
// TODO 자동 생성된 메소드 스텁
}
});
}
public static void main(String[] args)
{
new Ch1101();
}
}