From d645c28986395aca4c27aec7c4e848972b0bc2e2 Mon Sep 17 00:00:00 2001 From: luchsh Date: Mon, 11 Jun 2012 10:52:31 +0800 Subject: [PATCH] 7155887: ComboBox does not display focus outline in GTK L&F Reviewed-by: rupashka --- .../sun/java/swing/plaf/gtk/GTKPainter.java | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java index 57a816932..4a1f429ba 100644 --- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java @@ -926,9 +926,20 @@ class GTKPainter extends SynthPainter { int x, int y, int w, int h) { // Text is odd in that it uses the TEXT_BACKGROUND vs BACKGROUND. JComponent c = context.getComponent(); + Container container = c.getParent(); + Container containerParent = null; GTKStyle style = (GTKStyle)context.getStyle(); Region id = context.getRegion(); int state = context.getComponentState(); + + if (c instanceof ListCellRenderer && container != null) { + containerParent = container.getParent(); + if (containerParent instanceof JComboBox + && containerParent.hasFocus()) { + state |= SynthConstants.FOCUSED; + } + } + synchronized (UNIXToolkit.GTK_LOCK) { if (ENGINE.paintCachedImage(g, x, y, w, h, id, state)) { return; @@ -938,9 +949,10 @@ class GTKPainter extends SynthPainter { int focusSize = 0; boolean interiorFocus = style.getClassSpecificBoolValue( context, "interior-focus", true); + + focusSize = style.getClassSpecificIntValue(context, + "focus-line-width",1); if (!interiorFocus && (state & SynthConstants.FOCUSED) != 0) { - focusSize = style.getClassSpecificIntValue(context, - "focus-line-width",1); x += focusSize; y += focusSize; w -= 2 * focusSize; @@ -961,11 +973,25 @@ class GTKPainter extends SynthPainter { h - (2 * yThickness), ColorType.TEXT_BACKGROUND); - if (focusSize > 0) { - x -= focusSize; - y -= focusSize; - w += 2 * focusSize; - h += 2 * focusSize; + if (focusSize > 0 && (state & SynthConstants.FOCUSED) != 0) { + if (!interiorFocus) { + x -= focusSize; + y -= focusSize; + w += 2 * focusSize; + h += 2 * focusSize; + } else { + if (containerParent instanceof JComboBox) { + x += (focusSize + 2); + y += (focusSize + 1); + w -= (2 * focusSize + 1); + h -= (2 * focusSize + 2); + } else { + x += focusSize; + y += focusSize; + w -= 2 * focusSize; + h -= 2 * focusSize; + } + } ENGINE.paintFocus(g, context, id, gtkState, "entry", x, y, w, h); } -- GitLab