--- old/src/macosx/classes/sun/lwawt/LWWindowPeer.java 2013-04-17 11:10:56.298811300 +0400 +++ new/src/macosx/classes/sun/lwawt/LWWindowPeer.java 2013-04-17 11:10:56.090803700 +0400 @@ -41,7 +41,7 @@ public class LWWindowPeer extends LWContainerPeer - implements WindowPeer, FramePeer, DialogPeer, FullScreenCapable + implements FramePeer, DialogPeer, FullScreenCapable, DisplayChangedListener { public static enum PeerType { SIMPLEWINDOW, @@ -189,6 +189,7 @@ if (getSurfaceData() == null) { replaceSurfaceData(false); } + activateDisplayListener(); } // Just a helper method @@ -210,6 +211,7 @@ @Override protected void disposeImpl() { + deactivateDisplayListener(); SurfaceData oldData = getSurfaceData(); synchronized (surfaceDataLock){ surfaceData = null; @@ -880,6 +882,18 @@ // ---- UTILITY METHODS ---- // + private void activateDisplayListener() { + final GraphicsEnvironment ge = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + ((SunGraphicsEnvironment) ge).addDisplayChangedListener(this); + } + + private void deactivateDisplayListener() { + final GraphicsEnvironment ge = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + ((SunGraphicsEnvironment) ge).removeDisplayChangedListener(this); + } + private void postWindowStateChangedEvent(int newWindowState) { if (getTarget() instanceof Frame) { AWTAccessor.getFrameAccessor().setExtendedState( @@ -941,7 +955,6 @@ graphicsDevice = newGraphicsDevice; } - // TODO: DisplayChangedListener stuff final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration(); if (!setGraphicsConfig(newGC)) return false; @@ -954,6 +967,20 @@ return true; } + @Override + public final void displayChanged() { + updateGraphicsDevice(); + // Replace surface unconditionally, because internal state of the + // GraphicsDevice could be changed. + replaceSurfaceData(); + repaintPeer(); + } + + @Override + public final void paletteChanged() { + // components do not need to react to this event. + } + /* * May be called by delegate to provide SD to Java2D code. */