달력

3

« 2024/3 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'awt'에 해당되는 글 1

  1. 2011.07.20 AWT Frame 윈도우 정 가운데에 오기
2011. 7. 20. 16:51

AWT Frame 윈도우 정 가운데에 오기 Study/Java2011. 7. 20. 16:51


import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;

public class MyFrame {

public static void main(String[] args){

Frame f = new Frame("AWT TEST");

//윈도우 사이즈 구하기
Dimension dim1 = Toolkit.getDefaultToolkit().getScreenSize(); 

//Frame 사이즈 구하기
Dimension dim2 = f.getSize();  

f.setVisible(true);

//Frame 윈도우 가운데에 띄우기 공식
f.setLocation((int)dim1.getWidth()/2-(int)dim2.getWidth()/2, 
                                                         (int)dim1.getHeight()/2-(int)dim2.getHeight()/2);

}

}


 

:
Posted by 유쾌한순례자