`

将swt窗口居中(屏幕中间)将swing窗口居中

阅读更多

将swt窗口居中

		    Dimension dem=Toolkit.getDefaultToolkit().getScreenSize();
		    int sHeight=dem.height;
		    int sWidth=dem.width;
		    int fHeight=shell.getSize().y;
		    int fWidth=shell.getSize().x;
		    shell.setLocation((sWidth-fWidth)/2, (sHeight-fHeight)/2);

 将swing窗口居中

Dimension dem=Toolkit.getDefaultToolkit().getScreenSize();
  int sHeight=dem.height;
  int sWidth=dem.width;
  int fHeight=this.getHeight();
  int fWidth=this.getWidth();
  this.setLocation((sWidth-fWidth)/2, (sHeight-fHeight)/2);
 

 

 

 

 

1
0
分享到:
评论
1 楼 wxq594808632 2010-03-24  
swing一般用这个
 setLocationRelativeTo(null);

相关推荐

Global site tag (gtag.js) - Google Analytics