--- old/src/macosx/classes/sun/lwawt/LWWindowPeer.java 2012-05-31 17:13:40.958138600 +0400 +++ new/src/macosx/classes/sun/lwawt/LWWindowPeer.java 2012-05-31 17:13:40.770938300 +0400 @@ -145,8 +145,6 @@ // similar to what Apple's Java do. // Since JDK7 we should rely on setOpacity() only. // this.opacity = c.getAlpha(); - // System.out.println("Delegate assigns alpha (we ignore setOpacity()):" - // +this.opacity); } if (!target.isForegroundSet()) { @@ -159,23 +157,29 @@ } @Override - public void initialize() { + void initializeImpl() { + super.initializeImpl(); if (getTarget() instanceof Frame) { - setTitle(((Frame)getTarget()).getTitle()); - setState(((Frame)getTarget()).getExtendedState()); + setTitle(((Frame) getTarget()).getTitle()); + setState(((Frame) getTarget()).getExtendedState()); } else if (getTarget() instanceof Dialog) { - setTitle(((Dialog)getTarget()).getTitle()); + setTitle(((Dialog) getTarget()).getTitle()); } setAlwaysOnTop(getTarget().isAlwaysOnTop()); updateMinimumSize(); - setOpacity(getTarget().getOpacity()); - setOpaque(getTarget().isOpaque()); + final float opacity = getTarget().getOpacity(); + if (opacity < 1.0f) { + setOpacity(opacity); + } - super.initialize(); + setOpaque(getTarget().isOpaque()); updateInsets(platformWindow.getInsets()); + if (getSurfaceData() == null) { + replaceSurfaceData(); + } } // Just a helper method @@ -213,25 +217,18 @@ } @Override - public void setVisible(final boolean visible) { - if (getSurfaceData() == null) { - replaceSurfaceData(); - } - - if (isVisible() == visible) { - return; - } - super.setVisible(visible); - + protected void setVisibleImpl(final boolean visible) { + super.setVisibleImpl(visible); // TODO: update graphicsConfig, see 4868278 - // TODO: don't notify the delegate if our visibility is unchanged - - // it is important to call this method on EDT - // to prevent the deadlocks during the painting of the lightweight delegates - //TODO: WHY? This is a native-system related call. Perhaps NOT calling - // the painting procedure right from the setVisible(), but rather relying - // on the native Expose event (or, scheduling the repainting asynchronously) - // is better? + // In the super.setVisibleImpl() we post PaintEvent to EDT. + // Then we schedule this method on EDT too. So we'll have correct + // texture at the time when the window will appear on the screen and + // we'll simply make the blit in the native callback. + // invokeLater() can be deleted, but in this case we get a lag between + // windows showing and content painting. + // Note: don't forget to delete invokeLater from CPlatformWindow.dispose + // if this one will be deleted. + // TODO if EDT is blocked we cannot show the window. SwingUtilities.invokeLater(new Runnable() { @Override public void run() { @@ -982,8 +979,9 @@ Graphics g = backBuffer.getGraphics(); try { Rectangle r = getBounds(); - g.setColor(getBackground()); - g.fillRect(0, 0, r.width, r.height); + g.setColor(getForeground()); + ((Graphics2D) g).setBackground(getBackground()); + g.clearRect(0, 0, r.width, r.height); if (oldBB != null) { // Draw the old back buffer to the new one g.drawImage(oldBB, 0, 0, null);