반응형
main 문
===========================================================
import java.awt.event.ActionListener;
public class todo_main {
public static void main(String[] args){
todo a=new todo("오늘에 할일!");
}
}
===========================================================
/*
MyFrame 소스 학원에서 좀더 편하게
코딩하기 위해 선생님께서 알려주신것 .
* Frame클래스 상속 받아서 재정의하여 사용
*/
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class MyFrame extends Frame {
MyFrame(String winName) {
super(winName); //Frame(Sring str);
this.setSize(300, 400); // 크기!
Dimension window = Toolkit.getDefaultToolkit().getScreenSize(); //화면 설정 크기
Dimension frame = super.getSize(); //프레임의 크기
// 중앙에 위치
int xPos = (int) (window.getWidth() / 2 - frame.getWidth() / 2);
int yPos = (int) (window.getHeight() / 2 - frame.getHeight() / 2);
// this.setResizable(false);
this.setLocation(xPos, yPos);
//종료 처리
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
//컴퍼넌트 처리 위치 때문에 분리~~
public void setVisible(boolean b) {
super.setVisible(b);
}
}
/*
*
*/
===================================================================
public class todo extends MyFrame {
todo(String winName) {
super(winName);
init();
this.setVisible(true);
// TODO Auto-generated constructor stub
}
}
super(winName);
init();
this.setVisible(true);
// TODO Auto-generated constructor stub
}
}
}
반응형