囝泺的博客[www.bluenuo.cn]

网盘[disk.bluenuo.cn]
随笔 - 6, 文章 - 1, 评论 - 11, 引用 - 0
数据加载中……

主窗口居中显示

文/囝泺 www.bluenuo.cn

 

shell = new Shell();
shell.setSize(
500375);
    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 囝泺 阅读(348) 评论(0)  编辑  收藏 所属分类: SWT/JFace


只有注册用户登录后才能发表评论。


网站导航: