Browse Source

Make ui classes shared if applicable.

pull/198/head
weisj 5 years ago
parent
commit
57086643f9
  1. 3
      core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java
  2. 6
      core/src/main/java/com/github/weisj/darklaf/ui/panel/DarkPanelUI.java

3
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 { public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener {
protected static final DarkLabelUI darkLabelUI = new DarkLabelUI(); protected static DarkLabelUI darkLabelUI;
private Color inactiveForeground; private Color inactiveForeground;
@ -56,6 +56,7 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
} }
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
if (darkLabelUI == null) darkLabelUI = new DarkLabelUI();
return darkLabelUI; return darkLabelUI;
} }

6
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.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.PanelUI;
import javax.swing.plaf.basic.BasicPanelUI; import javax.swing.plaf.basic.BasicPanelUI;
/** /**
@ -33,7 +34,10 @@ import javax.swing.plaf.basic.BasicPanelUI;
*/ */
public class DarkPanelUI extends BasicPanelUI { public class DarkPanelUI extends BasicPanelUI {
private static PanelUI darkPanelUI;
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
return new DarkPanelUI(); if (darkPanelUI == null) darkPanelUI = new DarkPanelUI();
return darkPanelUI;
} }
} }

Loading…
Cancel
Save