From d42310f04f90f5dc90e03549317d310b0b879c24 Mon Sep 17 00:00:00 2001 From: weisj Date: Wed, 18 Mar 2020 23:43:54 +0100 Subject: [PATCH] Fixed string VARIANT_* properties not being applied to tooltip style. --- .../darklaf/ui/tooltip/DarkTooltipUI.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java index dff5ee01..95c47991 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java @@ -52,6 +52,7 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe public static final String KEY_PLAIN_TOOLTIP = "JComponent.plainTooltip"; public static final String VARIANT_PLAIN = "plain"; public static final String VARIANT_BALLOON = "balloon"; + public static final String VARIANT_PLAIN_BALLOON = "plainBalloon"; public static final String TIP_TEXT_PROPERTY = "tiptext"; public static final String KEY_PAINT_ALPHA = KEY_PREFIX + "paintAlpha"; public static final String KEY_CONTEXT = KEY_PREFIX + "toolTipContext"; @@ -340,14 +341,23 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe private void updateStyle() { JComponent comp = toolTip.getComponent(); if (comp != null) { - Object style = comp.getClientProperty(KEY_STYLE); - Object tooltipStyle = toolTip.getClientProperty(KEY_STYLE); - toolTip.putClientProperty(KEY_STYLE, style instanceof ToolTipStyle ? style : - tooltipStyle instanceof ToolTipStyle ? tooltipStyle - : ToolTipStyle.PLAIN_BALLOON); + ToolTipStyle style = getStyle(comp.getClientProperty(KEY_STYLE)); + ToolTipStyle tooltipStyle = getStyle(toolTip.getClientProperty(KEY_STYLE)); + toolTip.putClientProperty(KEY_STYLE, style != null ? style : + tooltipStyle != null ? tooltipStyle + : ToolTipStyle.PLAIN_BALLOON); } } + private ToolTipStyle getStyle(final Object style) { + if (style instanceof ToolTipStyle) return (ToolTipStyle) style; + String name = style.toString(); + if (VARIANT_PLAIN_BALLOON.equals(name)) return ToolTipStyle.PLAIN_BALLOON; + if (VARIANT_BALLOON.equals(name)) return ToolTipStyle.BALLOON; + if (VARIANT_PLAIN.equals(name)) return ToolTipStyle.PLAIN; + return null; + } + protected void updateSize() { toolTip.setTipText(toolTip.getTipText()); toolTip.setPreferredSize(getPreferredSize(toolTip));