如何设置窗口大小和位置?

Eclipse版本:3.4

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);
}

你可能感兴趣的:(eclipse,窗口,职场,休闲)