zoukankan      html  css  js  c++  java
  • Java eclipse中shell窗口怎么居中显示

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

    }

  • 相关阅读:
    I/O流
    宇宙第一帅的HTML笔记
    宇宙无敌第一帅的Java笔记
    Activity常用的方法
    Spinne
    安卓布局方式
    for循环
    TextView
    开发Activity步骤
    重写
  • 原文地址:https://www.cnblogs.com/emanlee/p/13340637.html
Copyright © 2011-2022 走看看