From 2e1a6abb064e3fe97b019e733c0cde2faf6266bf Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Tue, 15 May 2012 19:22:30 +0400 Subject: [PATCH] In JBTabsImpl.paintChildren() course, selected tab child is paint separately, with JComponent's paintChildren unaware of this, and not setting ANCESTOR_USING_BUFFER flag. Thus, label component is drawn to the buffer without being aware of it. This causes coordinate mapping problems. The workaround is to make sure none of the components, that TabLabel consists of uses double buffering. --- .../ui/components/panels/NonOpaquePanel.java | 1 + .../com/intellij/ui/tabs/impl/TabLabel.java | 30 +++++++------------ .../src/com/intellij/util/ui/Centerizer.java | 3 +- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/components/panels/NonOpaquePanel.java b/platform/platform-api/src/com/intellij/ui/components/panels/NonOpaquePanel.java index a0f0f82019ef..442f94595cd1 100644 --- a/platform/platform-api/src/com/intellij/ui/components/panels/NonOpaquePanel.java +++ b/platform/platform-api/src/com/intellij/ui/components/panels/NonOpaquePanel.java @@ -53,6 +53,7 @@ public class NonOpaquePanel extends Wrapper { @Override public void setOpaque(boolean isOpaque) { super.setOpaque(isOpaque); + setDoubleBuffered(false); if (!isOpaque && UIUtil.isUnderNimbusLookAndFeel()) { if (UIUtil.isUnderNimbusLookAndFeel()) { diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java index 4fe4fd6dd449..0c512c632510 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabLabel.java @@ -58,15 +58,15 @@ public class TabLabel extends JPanel { protected ActionPanel myActionPanel; private boolean myCentered; - private final Wrapper myLabelPlaceholder = new Wrapper(); + private final Wrapper myLabelPlaceholder = new Wrapper(false); private final JBTabsImpl myTabs; - private BufferedImage myImage; - private BufferedImage myInactiveStateImage; private Rectangle myLastPaintedInactiveImageBounds; public TabLabel(JBTabsImpl tabs, final TabInfo info) { + super(false); + myTabs = tabs; myInfo = info; myLabel.setOpaque(false); @@ -147,13 +147,7 @@ public class TabLabel extends JPanel { if (myTabs.isDropTarget(myInfo)) return; if (myTabs.getSelectedInfo() != myInfo) { - myImage = null; doPaint(g); - } else if (!SystemInfo.isMac || SystemInfo.isJavaVersionAtLeast("1.7")) { - myImage = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); - final Graphics2D lg = myImage.createGraphics(); - doPaint(lg); - lg.dispose(); } } @@ -169,17 +163,13 @@ public class TabLabel extends JPanel { public void paintImage(Graphics g) { final Rectangle b = getBounds(); - if (myImage != null) { - g.drawImage(myImage, b.x, b.y, getWidth(), getHeight(), null); - } else { - final Graphics lG = g.create(b.x, b.y, b.width, b.height); - try { - lG.setColor(Color.red); - doPaint(lG); - } - finally { - lG.dispose(); - } + final Graphics lG = g.create(b.x, b.y, b.width, b.height); + try { + lG.setColor(Color.red); + doPaint(lG); + } + finally { + lG.dispose(); } } diff --git a/platform/util/src/com/intellij/util/ui/Centerizer.java b/platform/util/src/com/intellij/util/ui/Centerizer.java index 9b747d9df2cb..4f42ca3352de 100644 --- a/platform/util/src/com/intellij/util/ui/Centerizer.java +++ b/platform/util/src/com/intellij/util/ui/Centerizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.awt.*; public class Centerizer extends JPanel { public Centerizer(@NotNull JComponent comp) { + super(false); setOpaque(false); setBorder(null);