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窗口怎么居中显示
原创
©著作权归作者所有:来自51CTO博客作者emanlee的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java构造方法中怎么对字段初始化
java构造方法中怎么对字段初始化
构造方法 字段 初始化 -
MFC编程 -- 运行窗口居中显示
一、源代码int 窗口初始化(HWND hDlg){ RECT rect; GetWindowRect(hDlg,&rect);//
mfc c++ 公众号 初始化 移动窗口 -
打开居中显示的窗口
打开居中显示的窗口
html5课程 微信 人工智能 大数据 居中显示 -
java居中对齐代码 java怎么居中显示
java swing 子窗口居中_Java Swing实现让窗体居中显示的方法示例
java swing 子窗口居中 Java Swing 居中显示