From 57086643f9f0be812302e4cee286f9f6d90747ac Mon Sep 17 00:00:00 2001 From: weisj Date: Tue, 7 Jul 2020 09:50:59 +0200 Subject: [PATCH] Make ui classes shared if applicable. --- .../java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java | 3 ++- .../java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java index 4260695c..d7ff6ecc 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java @@ -44,7 +44,7 @@ import com.github.weisj.darklaf.util.PropertyKey; */ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener { - protected static final DarkLabelUI darkLabelUI = new DarkLabelUI(); + protected static DarkLabelUI darkLabelUI; private Color inactiveForeground; @@ -56,6 +56,7 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener } public static ComponentUI createUI(final JComponent c) { + if (darkLabelUI == null) darkLabelUI = new DarkLabelUI(); return darkLabelUI; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java index 794f97f9..fef05946 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java @@ -26,6 +26,7 @@ package com.github.weisj.darklaf.ui.panel; import javax.swing.*; import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.PanelUI; import javax.swing.plaf.basic.BasicPanelUI; /** @@ -33,7 +34,10 @@ import javax.swing.plaf.basic.BasicPanelUI; */ public class DarkPanelUI extends BasicPanelUI { + private static PanelUI darkPanelUI; + public static ComponentUI createUI(final JComponent c) { - return new DarkPanelUI(); + if (darkPanelUI == null) darkPanelUI = new DarkPanelUI(); + return darkPanelUI; } }