From e33e366adf26a1318bcb3d88f4911b2ad10ed93c Mon Sep 17 00:00:00 2001 From: weisj Date: Wed, 18 Mar 2020 23:55:11 +0100 Subject: [PATCH] Fixed string property for tooltip style not being respected. --- .../com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java | 3 ++- .../java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java | 3 ++- core/src/test/java/ui/toolTip/ToolTipDemo.java | 1 + 3 files changed, 5 insertions(+), 2 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 95c47991..92c65801 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 @@ -349,8 +349,9 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe } } - private ToolTipStyle getStyle(final Object style) { + public static ToolTipStyle getStyle(final Object style) { if (style instanceof ToolTipStyle) return (ToolTipStyle) style; + if (style == null) return null; String name = style.toString(); if (VARIANT_PLAIN_BALLOON.equals(name)) return ToolTipStyle.PLAIN_BALLOON; if (VARIANT_BALLOON.equals(name)) return ToolTipStyle.BALLOON; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java index 247a9f6e..964ea5bb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tooltip/ToolTipUtil.java @@ -133,7 +133,8 @@ public class ToolTipUtil { if (context instanceof ToolTipContext) { return (ToolTipContext) context; } - if (ToolTipStyle.BALLOON.equals(comp.getClientProperty(DarkTooltipUI.KEY_STYLE))) { + Object style = comp.getClientProperty(DarkTooltipUI.KEY_STYLE); + if (ToolTipStyle.BALLOON.equals(DarkTooltipUI.getStyle(style))) { return DEFAULT_CONTEXT; } return null; diff --git a/core/src/test/java/ui/toolTip/ToolTipDemo.java b/core/src/test/java/ui/toolTip/ToolTipDemo.java index 362187a6..1dbce070 100644 --- a/core/src/test/java/ui/toolTip/ToolTipDemo.java +++ b/core/src/test/java/ui/toolTip/ToolTipDemo.java @@ -47,6 +47,7 @@ public class ToolTipDemo implements ComponentDemo { .setCenterAlignment(Alignment.SOUTH); button.putClientProperty(DarkTooltipUI.KEY_CONTEXT, context); button.setToolTipText("This is the ToolTip demo text!"); + button.putClientProperty(DarkTooltipUI.KEY_STYLE, DarkTooltipUI.VARIANT_BALLOON); JPanel controlPanel = panel.addControls();