--- old/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java 2017-03-04 08:27:23.004677400 +0300 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java 2017-03-04 08:27:22.597287000 +0300 @@ -38,6 +38,7 @@ import sun.awt.*; import sun.java2d.pipe.Region; +import sun.swing.SwingUtilities2; public class WWindowPeer extends WPanelPeer implements WindowPeer, DisplayChangedListener @@ -630,9 +631,42 @@ sysW = width; sysH = height; + int cx = x + width / 2; + int cy = y + height / 2; + GraphicsConfiguration current = getGraphicsConfiguration(); + GraphicsConfiguration other = SwingUtilities2.getGraphicsConfigurationAtPoint(current, cx, cy); + if (!current.equals(other)) { + AffineTransform tx = other.getDefaultTransform(); + double otherScaleX = tx.getScaleX(); + double otherScaleY = tx.getScaleY(); + initScales(); + if (scaleX != otherScaleX || scaleY != otherScaleY) { + x = (int) Math.floor(x * otherScaleX / scaleX); + y = (int) Math.floor(y * otherScaleY / scaleY); + } + } + super.setBounds(x, y, width, height, op); } + private final void initScales() { + + if (scaleX >= 1 && scaleY >= 1) { + return; + } + + GraphicsConfiguration gc = getGraphicsConfiguration(); + if (gc instanceof Win32GraphicsConfig) { + Win32GraphicsDevice gd = ((Win32GraphicsConfig) gc).getDevice(); + scaleX = gd.getDefaultScaleX(); + scaleY = gd.getDefaultScaleY(); + } else { + AffineTransform tx = gc.getDefaultTransform(); + scaleX = (float) tx.getScaleX(); + scaleY = (float) tx.getScaleY(); + } + } + @Override public void print(Graphics g) { // We assume we print the whole frame,