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.

This commit is contained in:
Maxim Shafirov
2012-05-15 19:24:50 +04:00
parent 937cf22ce1
commit 2e1a6abb06
3 changed files with 13 additions and 21 deletions
@@ -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()) {
@@ -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();
}
}
@@ -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);