diff --git a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java index 2dbde896..8e731cba 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java @@ -40,6 +40,25 @@ import java.util.function.Function; public class ToolTipContext { + private static ToolTipContext defaultContext; + + public static ToolTipContext getDefaultContext() { + if (defaultContext == null) defaultContext = createDefaultContext(); + return defaultContext; + } + + private static ToolTipContext createDefaultContext() { + return new ToolTipContext().setAlignment(Alignment.SOUTH) + .setCenterAlignment(Alignment.SOUTH) + .setAlignInside(false) + .setIgnoreBorder(true) + .setUseBestFit(true); + } + + public static void setDefaultContext(final ToolTipContext defaultContext) { + ToolTipContext.defaultContext = defaultContext; + } + private final Insets calcInsets = new Insets(0, 0, 0, 0); private JComponent target; private final MouseListener mouseListener = new MouseAdapter() { 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 2d20846c..7154043f 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 @@ -34,12 +34,6 @@ import java.util.function.BiConsumer; public class ToolTipUtil { - private final static ToolTipContext DEFAULT_CONTEXT = new ToolTipContext().setAlignment(Alignment.SOUTH) - .setCenterAlignment(Alignment.SOUTH) - .setAlignInside(false) - .setIgnoreBorder(true) - .setUseBestFit(true); - public static void applyContext(final JToolTip toolTip) { JComponent target = toolTip.getComponent(); if (target == null) return; @@ -150,7 +144,7 @@ public class ToolTipUtil { } Object style = tooltip.getComponent().getClientProperty(DarkTooltipUI.KEY_STYLE); if (ToolTipStyle.BALLOON.equals(DarkTooltipUI.getStyle(style))) { - return DEFAULT_CONTEXT; + return ToolTipContext.getDefaultContext(); } return null; }