From 96388be1b59f90d226438917c6f5400bb0af5106 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 27 Nov 2024 08:24:01 +0000 Subject: [PATCH] 8345004: [BACKOUT] GTK & Nimbus LAF: Tabbed pane's background color is not expected one when change the opaque checkbox. Reviewed-by: psadhukhan, kizune --- .../java/swing/plaf/gtk/GTKLookAndFeel.java | 7 ---- .../sun/java/swing/plaf/gtk/GTKPainter.java | 33 +++++++-------- .../swing/plaf/nimbus/SynthPainterImpl.java | 39 ++++++++---------- .../classes/javax/swing/plaf/nimbus/skin.laf | 10 +---- .../swing/plaf/synth/SynthTabbedPaneUI.java | 41 +------------------ test/jdk/ProblemList.txt | 1 + 6 files changed, 35 insertions(+), 96 deletions(-) diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java index 9490dc6bdff..480b8bacb30 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java @@ -356,8 +356,6 @@ public class GTKLookAndFeel extends SynthLookAndFeel { Double defaultCaretAspectRatio = Double.valueOf(0.025); Color caretColor = table.getColor("caretColor"); Color controlText = table.getColor("controlText"); - Color tabbedPaneBg = new ColorUIResource(238, 238, 238); - Color unselectedTabColor = new ColorUIResource(255, 255, 255); Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] { "ctrl C", DefaultEditorKit.copyAction, @@ -1029,11 +1027,6 @@ public class GTKLookAndFeel extends SynthLookAndFeel { "TabbedPane.selectedLabelShift", 3, "TabbedPane.font", new FontLazyValue(Region.TABBED_PANE), "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 0, 1), - "TabbedPane.selected", tabbedPaneBg, - "TabbedPane.contentOpaque", Boolean.TRUE, - "TabbedPane.tabsOpaque", Boolean.TRUE, - "TabbedPane.contentAreaColor", tabbedPaneBg, - "TabbedPane.unselectedBackground", unselectedTabColor, "Table.scrollPaneBorder", zeroBorder, "Table.background", tableBg, diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java index ea27a2a6e0d..fa28eb3ca71 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java @@ -935,27 +935,22 @@ class GTKPainter extends SynthPainter { Graphics g, int x, int y, int w, int h, int tabIndex) { + Region id = context.getRegion(); + int state = context.getComponentState(); + int gtkState = ((state & SynthConstants.SELECTED) != 0 ? + SynthConstants.ENABLED : SynthConstants.PRESSED); JTabbedPane pane = (JTabbedPane)context.getComponent(); - if (UIManager.getBoolean("TabbedPane.tabsOpaque") || pane.isOpaque()) { - Region id = context.getRegion(); - int state = context.getComponentState(); - int gtkState = ((state & SynthConstants.SELECTED) != 0 ? - SynthConstants.ENABLED : SynthConstants.PRESSED); - int placement = pane.getTabPlacement(); + int placement = pane.getTabPlacement(); - // Fill the tab rect area - g.fillRect(x, y, w, h); - - synchronized (UNIXToolkit.GTK_LOCK) { - if (!ENGINE.paintCachedImage(g, x, y, w, h, - id, gtkState, placement, tabIndex)) { - PositionType side = POSITIONS[placement - 1]; - ENGINE.startPainting(g, x, y, w, h, - id, gtkState, placement, tabIndex); - ENGINE.paintExtension(g, context, id, gtkState, - ShadowType.OUT, "tab", x, y, w, h, side, tabIndex); - ENGINE.finishPainting(); - } + synchronized (UNIXToolkit.GTK_LOCK) { + if (!ENGINE.paintCachedImage(g, x, y, w, h, + id, gtkState, placement, tabIndex)) { + PositionType side = POSITIONS[placement - 1]; + ENGINE.startPainting(g, x, y, w, h, + id, gtkState, placement, tabIndex); + ENGINE.paintExtension(g, context, id, gtkState, + ShadowType.OUT, "tab", x, y, w, h, side, tabIndex); + ENGINE.finishPainting(); } } } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/SynthPainterImpl.java b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/SynthPainterImpl.java index 96ef2541c7b..ca19a74b6ac 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/SynthPainterImpl.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/SynthPainterImpl.java @@ -2111,27 +2111,24 @@ class SynthPainterImpl extends SynthPainter { public void paintTabbedPaneTabBackground(SynthContext context, Graphics g, int x, int y, int w, int h, int tabIndex, int orientation) { - JTabbedPane pane = (JTabbedPane)context.getComponent(); - if (UIManager.getBoolean("TabbedPane.tabsOpaque") || pane.isOpaque()) { - if (orientation == JTabbedPane.LEFT) { - AffineTransform transform = new AffineTransform(); - transform.scale(-1, 1); - transform.rotate(Math.toRadians(90)); - paintBackground(context, g, y, x, h, w, transform); - } else if (orientation == JTabbedPane.RIGHT) { - AffineTransform transform = new AffineTransform(); - transform.rotate(Math.toRadians(90)); - transform.translate(0, -(x + w)); - paintBackground(context, g, y, 0, h, w, transform); - } else if (orientation == JTabbedPane.BOTTOM) { - AffineTransform transform = new AffineTransform(); - transform.translate(x, y); - transform.scale(1, -1); - transform.translate(0, -h); - paintBackground(context, g, 0, 0, w, h, transform); - } else { - paintBackground(context, g, x, y, w, h, null); - } + if (orientation == JTabbedPane.LEFT) { + AffineTransform transform = new AffineTransform(); + transform.scale(-1, 1); + transform.rotate(Math.toRadians(90)); + paintBackground(context, g, y, x, h, w, transform); + } else if (orientation == JTabbedPane.RIGHT) { + AffineTransform transform = new AffineTransform(); + transform.rotate(Math.toRadians(90)); + transform.translate(0, -(x + w)); + paintBackground(context, g, y, 0, h, w, transform); + } else if (orientation == JTabbedPane.BOTTOM) { + AffineTransform transform = new AffineTransform(); + transform.translate(x, y); + transform.scale(1, -1); + transform.translate(0, -h); + paintBackground(context, g, 0, 0, w, h, transform); + } else { + paintBackground(context, g, x, y, w, h, null); } } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf index 1d486f9fe06..38e8530983a 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf +++ b/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf @@ -1,7 +1,7 @@