囝濼的博客[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 囝濼 閱讀(361) 評論(0)  編輯  收藏 所屬分類: SWT/JFace


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 勐海县| 正阳县| 建阳市| 柳林县| 西吉县| 元氏县| 庐江县| 临湘市| 原阳县| 东兴市| 凤山市| 正宁县| 仁寿县| 儋州市| 醴陵市| 安塞县| 安庆市| 枣庄市| 大埔区| 湟中县| 旌德县| 会东县| 望奎县| 元朗区| 昌乐县| 亚东县| 新闻| 青州市| 嘉峪关市| 正蓝旗| 高青县| 乐昌市| 小金县| 留坝县| 独山县| 宽甸| 汉阴县| 治多县| 渝北区| 博白县| 龙岩市|