首页 > 编程语言 > 详细

Java eclipse中shell窗口怎么居中显示

时间:2020-07-19 18:41:01      阅读:105      评论:0      收藏:0      [点我收藏+]

 

protected void createContents() {
        shell = new Shell();
        shell.setSize(800, 600);
        shell.setText(title);

        int width=shell.getDisplay().getBounds().width;  // 找到createContents这个方法,得到屏幕的宽度。
        int height=shell.getDisplay().getBounds().height;  // 在这个方法中,得到屏幕的高度。
        // 得到屏幕的宽高度减去shell窗口的宽度和高度,除以2得到窗口的左上角坐标。
        int x=(width-shell.getBounds().width)/2;
        int y=(height-shell.getBounds().height)/2;
        shell.setLocation(x, y);

}

 

Java eclipse中shell窗口怎么居中显示

原文:https://www.cnblogs.com/emanlee/p/13340637.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!