List of usage examples for java.awt Window setLocationByPlatform
public void setLocationByPlatform(boolean locationByPlatform)
From source file:net.pms.newgui.components.WindowProperties.java
/** * Creates a new instance using the specified parameters. * * @param window the {@link Window} whose properties to keep track of. * @param standardSize the standard size of {@code window}. * @param mimimumSize the minimum size of {@code window}. * @param windowConfiguration the {@link WindowPropertiesConfiguration} * instance for reading and writing the window properties. *//*from w w w.jav a 2s .co m*/ public WindowProperties(@Nonnull Window window, @Nullable Dimension standardSize, @Nullable Dimension mimimumSize, @Nullable WindowPropertiesConfiguration windowConfiguration) { if (window == null) { throw new IllegalArgumentException("window cannot be null"); } this.window = window; this.minimumSize = mimimumSize; if (mimimumSize != null) { window.setMinimumSize(mimimumSize); } this.windowConfiguration = windowConfiguration; if (windowConfiguration != null) { getConfiguration(); GraphicsConfiguration windowGraphicsConfiguration = window.getGraphicsConfiguration(); if (windowBounds != null && effectiveScreenBounds != null && graphicsDevice != null && graphicsDevice.equals(windowGraphicsConfiguration.getDevice().getIDstring()) && screenBounds != null && screenBounds.equals(windowGraphicsConfiguration.getBounds())) { setWindowBounds(); } else { Rectangle screen = effectiveScreenBounds != null ? effectiveScreenBounds : windowGraphicsConfiguration.getBounds(); if (standardSize != null && screen.width >= standardSize.width && screen.height >= standardSize.height) { window.setSize(standardSize); } else if (mimimumSize != null && (window.getWidth() < mimimumSize.width || window.getHeight() < mimimumSize.getHeight())) { window.setSize(mimimumSize); } window.setLocationByPlatform(true); } if (window instanceof Frame) { // Set maximized state int maximizedState = windowState & Frame.MAXIMIZED_BOTH; if (maximizedState != 0) { ((Frame) window).setExtendedState(((Frame) window).getExtendedState() | maximizedState); } } } window.addWindowListener(this); window.addComponentListener(this); }