티스토리 뷰
import java.awt.*;
class OpenWin extends Frame{
public OpenWin(String title){
super(title);
super.setVisible(true);
// 창크기 조절
super.setSize(300, 200);
// 창을 화면 중앙으로 놓기..
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension f_size = super.getSize();
int xpos = (int)(screen.getWidth()/2 - f_size.getWidth()/2); // 원래는 Double 형태..
int ypos = (int)(screen.getHeight()/2 - f_size.getHeight()/2);
super.setLocation(xpos, ypos);
// 크기변경 불가
super.setResizable(false);
}
}
public class _1_1 {
public static void main(String[] args) {
OpenWin win = new OpenWin("제목");
}
}
import java.awt.*;
class OpenWin2 extends Frame{
private Label lb = new Label ("글자글자글자");
public OpenWin2(){
super("제목없음");
super.setVisible(true);
this.init();
// 창크기 조절
super.setSize(300, 200);
// 창을 화면 중앙으로 놓기..
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension f_size = super.getSize();
int xpos = (int)(screen.getWidth()/2 - f_size.getWidth()/2); // 원래는 Double 형태..
int ypos = (int)(screen.getHeight()/2 - f_size.getHeight()/2);
super.setLocation(xpos, ypos);
// 크기변경 불가
super.setResizable(false);
}
public OpenWin2(String title){
this();
this.setTitle(title);
}
public void init(){ // 화면 초기화 작업
this.add(lb);
}
}
public class _1_2 {
public static void main(String[] args) {
OpenWin2 win = new OpenWin2();
}
}
'dev > java' 카테고리의 다른 글
| Abstract Factory (0) | 2009.09.29 |
|---|---|
| JAVA AIP CSS 칼라 변경... (0) | 2009.05.01 |
| [16] 객체타입의 입출력 (0) | 2008.09.30 |
| JAVA.UTIL.SCANNER로 텍스트 스캔하기 (0) | 2008.09.30 |
| [16] Scanner 클래스로 입력 (0) | 2008.09.29 |
공지사항
