Skip to content

Commit 9ab8c6b

Browse files
author
Abhishek Kumar
committed
8335130: The test "javax/swing/plaf/synth/ComponentsOrientationSupport/5033822/bug5033822.java" fails because the background color of the tabs is displayed incorrectly.
Reviewed-by: achung, psadhukhan
1 parent 0c1e911 commit 9ab8c6b

File tree

3 files changed

+41
-40
lines changed

3 files changed

+41
-40
lines changed

src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -935,25 +935,27 @@ public void paintTabbedPaneTabBackground(SynthContext context,
935935
Graphics g,
936936
int x, int y, int w, int h,
937937
int tabIndex) {
938-
Region id = context.getRegion();
939-
int state = context.getComponentState();
940-
int gtkState = ((state & SynthConstants.SELECTED) != 0 ?
941-
SynthConstants.ENABLED : SynthConstants.PRESSED);
942938
JTabbedPane pane = (JTabbedPane)context.getComponent();
943-
int placement = pane.getTabPlacement();
939+
if (UIManager.getBoolean("TabbedPane.tabsOpaque") || pane.isOpaque()) {
940+
Region id = context.getRegion();
941+
int state = context.getComponentState();
942+
int gtkState = ((state & SynthConstants.SELECTED) != 0 ?
943+
SynthConstants.ENABLED : SynthConstants.PRESSED);
944+
int placement = pane.getTabPlacement();
944945

945-
// Fill the tab rect area
946-
g.fillRect(x, y, w, h);
946+
// Fill the tab rect area
947+
g.fillRect(x, y, w, h);
947948

948-
synchronized (UNIXToolkit.GTK_LOCK) {
949-
if (! ENGINE.paintCachedImage(g, x, y, w, h,
950-
id, gtkState, placement, tabIndex)) {
951-
PositionType side = POSITIONS[placement - 1];
952-
ENGINE.startPainting(g, x, y, w, h,
953-
id, gtkState, placement, tabIndex);
954-
ENGINE.paintExtension(g, context, id, gtkState,
955-
ShadowType.OUT, "tab", x, y, w, h, side, tabIndex);
956-
ENGINE.finishPainting();
949+
synchronized (UNIXToolkit.GTK_LOCK) {
950+
if (!ENGINE.paintCachedImage(g, x, y, w, h,
951+
id, gtkState, placement, tabIndex)) {
952+
PositionType side = POSITIONS[placement - 1];
953+
ENGINE.startPainting(g, x, y, w, h,
954+
id, gtkState, placement, tabIndex);
955+
ENGINE.paintExtension(g, context, id, gtkState,
956+
ShadowType.OUT, "tab", x, y, w, h, side, tabIndex);
957+
ENGINE.finishPainting();
958+
}
957959
}
958960
}
959961
}

src/java.desktop/share/classes/javax/swing/plaf/nimbus/SynthPainterImpl.java

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,24 +2098,27 @@ public void paintTabbedPaneTabBackground(SynthContext context, Graphics g,
20982098
public void paintTabbedPaneTabBackground(SynthContext context, Graphics g,
20992099
int x, int y, int w, int h,
21002100
int tabIndex, int orientation) {
2101-
if (orientation == JTabbedPane.LEFT) {
2102-
AffineTransform transform = new AffineTransform();
2103-
transform.scale(-1, 1);
2104-
transform.rotate(Math.toRadians(90));
2105-
paintBackground(context, g, y, x, h, w, transform);
2106-
} else if (orientation == JTabbedPane.RIGHT) {
2107-
AffineTransform transform = new AffineTransform();
2108-
transform.rotate(Math.toRadians(90));
2109-
transform.translate(0, -(x + w));
2110-
paintBackground(context, g, y, 0, h, w, transform);
2111-
} else if (orientation == JTabbedPane.BOTTOM) {
2112-
AffineTransform transform = new AffineTransform();
2113-
transform.translate(x,y);
2114-
transform.scale(1, -1);
2115-
transform.translate(0,-h);
2116-
paintBackground(context, g, 0, 0, w, h, transform);
2117-
} else {
2118-
paintBackground(context, g, x, y, w, h, null);
2101+
JTabbedPane pane = (JTabbedPane)context.getComponent();
2102+
if (UIManager.getBoolean("TabbedPane.tabsOpaque") || pane.isOpaque()) {
2103+
if (orientation == JTabbedPane.LEFT) {
2104+
AffineTransform transform = new AffineTransform();
2105+
transform.scale(-1, 1);
2106+
transform.rotate(Math.toRadians(90));
2107+
paintBackground(context, g, y, x, h, w, transform);
2108+
} else if (orientation == JTabbedPane.RIGHT) {
2109+
AffineTransform transform = new AffineTransform();
2110+
transform.rotate(Math.toRadians(90));
2111+
transform.translate(0, -(x + w));
2112+
paintBackground(context, g, y, 0, h, w, transform);
2113+
} else if (orientation == JTabbedPane.BOTTOM) {
2114+
AffineTransform transform = new AffineTransform();
2115+
transform.translate(x, y);
2116+
transform.scale(1, -1);
2117+
transform.translate(0, -h);
2118+
paintBackground(context, g, 0, 0, w, h, transform);
2119+
} else {
2120+
paintBackground(context, g, x, y, w, h, null);
2121+
}
21192122
}
21202123
}
21212124

src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
127127
// Background color for unselected tabs
128128
private Color unselectedBackground;
129129
private boolean contentOpaque = true;
130-
private boolean tabsOpaque = true;
131130

132131
/**
133132
*
@@ -156,7 +155,6 @@ private boolean scrollableTabLayoutEnabled() {
156155
protected void installDefaults() {
157156
selectColor = UIManager.getColor("TabbedPane.selected");
158157
contentOpaque = UIManager.getBoolean("TabbedPane.contentOpaque");
159-
tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
160158
unselectedBackground = UIManager.getColor("TabbedPane.unselectedBackground");
161159
updateStyle(tabPane);
162160
}
@@ -655,10 +653,8 @@ private void paintTab(SynthContext ss, Graphics g,
655653
g.setColor(getUnselectedBackgroundAt(tabIndex));
656654
}
657655

658-
if (tabsOpaque || tabPane.isOpaque()) {
659-
tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g,
660-
x, y, width, height, tabIndex, placement);
661-
}
656+
tabContext.getPainter().paintTabbedPaneTabBackground(tabContext, g,
657+
x, y, width, height, tabIndex, placement);
662658
tabContext.getPainter().paintTabbedPaneTabBorder(tabContext, g,
663659
x, y, width, height, tabIndex, placement);
664660

0 commit comments

Comments
 (0)