在
ApplicationWorkbenchWindowAdviso.java
文件,取得
Shell
对象,调用
Shell
对象的
setBounds()
接口来完成,示例如下:
public
void
postWindowCreate() {
super
.postWindowCreate();
//
窗口居中
Display display = Display.getDefault();
Rectangle rect = display.getBounds();
int
screenWidth = rect.
width
;
int
screenHeight = rect.
height
;
int
winWidth = 800;
int
winHeight = 600;
int
winX = (screenWidth - winWidth) / 2;
int
winY = (screenHeight - winHeight) / 2;
this
.getWindowConfigurer().getWindow().getShell().setBounds(winX, winY, winWidth, winHeight);
}
|
本文转自 tywali 51CTO博客,原文链接:http://blog.51cto.com/lancelot/118655,如需转载请自行联系原作者