--- old/src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java 2014-05-21 19:27:14.000000000 +0400 +++ new/src/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java 2014-05-21 19:27:14.000000000 +0400 @@ -29,12 +29,18 @@ import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.awt.Insets; import java.awt.MenuBar; import java.awt.Point; +import java.awt.Rectangle; import java.awt.Window; +import sun.awt.CGraphicsDevice; +import sun.awt.CGraphicsEnvironment; import sun.awt.CausedFocusEvent; +import sun.awt.LightweightFrame; import sun.java2d.SurfaceData; +import sun.lwawt.LWLightweightFramePeer; import sun.lwawt.LWWindowPeer; import sun.lwawt.PlatformWindow; @@ -73,11 +79,6 @@ } @Override - public GraphicsDevice getGraphicsDevice() { - return null; - } - - @Override public SurfaceData getScreenSurface() { return null; } @@ -199,4 +200,24 @@ public long getLayerPtr() { return 0; } + + @Override + public GraphicsDevice getGraphicsDevice() { + CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment. + getLocalGraphicsEnvironment(); + + LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer(); + int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor(); + + Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds(); + for (GraphicsDevice d : ge.getScreenDevices()) { + if (d.getDefaultConfiguration().getBounds().intersects(bounds) && + ((CGraphicsDevice)d).getScaleFactor() == scale) + { + return d; + } + } + // We shouldn't be here... + return ge.getDefaultScreenDevice(); + } }