Java GUI多屏幕的窗口设置
WorkbenchWindow window = (WorkbenchWindow) getWindowConfigurer().getWindow();
Shell shell = window.getShell();
Rectangle screenSize = Display.getDefault().getClientArea();
int sW = screenSize.width;
int sH = screenSize.height;
shell.setSize(new Point(sW, sH));
第一种方式
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
//获取除去任务栏的剩余区域
java.awt.Rectangle maximumWindowBounds = graphicsEnvironment.getMaximumWindowBounds();
//设置配载软件窗口大小和位置
shell.setBounds(maximumWindowBounds.x, maximumWindowBounds.y, maximumWindowBounds.width, maximumWindowBounds.height);
第二种方式
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] graphicsDevices = graphicsEnvironment.getScreenDevices();
//这种方式获取的是整个显示屏幕的大小,包含了任务栏的高度。
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(graphicsDevices[0].getDefaultConfiguration());
//获取除去任务栏的剩余区域
Rectangle maximumWindowBounds = new Rectangle(screenInsets.left, screenInsets.top,
screenSize.width - screenInsets.left - screenInsets.right,
screenSize.height - screenInsets.top - screenInsets.bottom);
shell.setBounds(maximumWindowBounds);