主窗口居中顯示
文/囝濼 www.bluenuo.cn


Monitor primary = shell.getMonitor();//獲得屏幕
Rectangle bounds = primary.getBounds ();//獲得屏幕尺寸
Rectangle rect = shell.getBounds ();//獲得窗口尺寸
int x = bounds.x + (bounds.width - rect.width) / 2;//計算x坐標
int y = bounds.y + (bounds.height - rect.height) / 2;//計算y坐標
if (x < 0)//判斷坐標是否在屏幕之外
x = 0;
if (y < 0)
y = 0;
shell.setLocation (x, y);//設置窗口坐標
shell.open();
囝濼,深圳康拓普信息技術有限公司
您可以通過其博客了解更多信息和文章:http://www.bluenuo.cn
posted on 2007-12-16 15:35 囝濼 閱讀(361) 評論(0) 編輯 收藏 所屬分類: SWT/JFace