diff --git a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java b/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java index 04a63a2a..6247e3b7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java +++ b/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java @@ -206,6 +206,9 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener Properties uiProps = new Properties(); final Theme currentTheme = LafManager.getTheme(); currentTheme.loadDefaults(uiProps, defaults); + //Load overwrites the user has set. + PropertyLoader.putProperties(LafManager.getUserProperties(), uiProps, defaults); + currentTheme.loadGlobals(uiProps, defaults); installGlobals(uiProps, defaults); currentTheme.loadUIProperties(uiProps, defaults); diff --git a/core/src/main/java/com/github/weisj/darklaf/LafManager.java b/core/src/main/java/com/github/weisj/darklaf/LafManager.java index 885cc254..49d9d33c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/LafManager.java +++ b/core/src/main/java/com/github/weisj/darklaf/LafManager.java @@ -33,6 +33,7 @@ import javax.swing.*; import java.awt.*; import java.io.IOException; import java.io.InputStream; +import java.util.Properties; import java.util.logging.Level; import java.util.logging.LogManager; import java.util.logging.Logger; @@ -47,6 +48,7 @@ public final class LafManager { private static Theme theme; private static boolean logEnabled = false; private static boolean decorationsOverwrite = true; + private static Properties properties = new Properties(); static { enableLogging(true); @@ -215,4 +217,66 @@ public final class LafManager { } } + /** + * Set a custom property. + *

+ * Note: These properties are loaded + * after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values + * specified in `[theme]_defaults.properties`. + * + * @param key the key. + * @param value the value. + */ + public static void setProperty(final String key, final String value) { + properties.setProperty(key, value); + } + + /** + * Remove a custom property. + *

+ * Note: These properties are loaded + * after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values + * specified in `[theme]_defaults.properties`. + * + * @param key the key. + */ + public static void removeProperty(final String key) { + properties.remove(key); + } + + /** + * Remove all custom properties. + *

+ * Note: These properties are loaded + * after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values + * specified in `[theme]_defaults.properties`. + */ + public static void clearProperties() { + properties.clear(); + } + + /** + * Get the custom properties. + *

+ * Note: These properties are loaded + * after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values + * specified in `[theme]_defaults.properties`. + */ + public static Properties getUserProperties() { + return properties; + } + + /** + * Remove a custom property. + *

+ * Note: These properties are loaded + * after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values + * specified in `[theme]_defaults.properties`. + * + * @param key the key. + * @return the value associated with `key`. + */ + public String getProperty(final String key) { + return properties.getProperty(key); + } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java index 440f1a42..a060f660 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java @@ -273,6 +273,7 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh @Override protected void installListeners() { + super.installListeners(); JTextComponent c = getComponent(); c.addMouseListener(mouseListener); c.addMouseMotionListener(mouseMotionListener);