From 93167b58978ff31aac55931d8c2cf6101de9d345 Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Mon, 1 May 2023 18:04:52 +0200 Subject: [PATCH] Apply visual paddings directly after installation --- .../github/weisj/darklaf/swingdsl/VisualPaddingListener.java | 4 ++++ .../java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java | 2 +- .../com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java | 2 +- .../com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java | 2 +- .../java/com/github/weisj/darklaf/ui/text/DarkTextUI.java | 2 +- .../ui/togglebutton/radiobutton/DarkRadioButtonUI.java | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/swingdsl/VisualPaddingListener.java b/core/src/main/java/com/github/weisj/darklaf/swingdsl/VisualPaddingListener.java index 0600339a..44da5177 100644 --- a/core/src/main/java/com/github/weisj/darklaf/swingdsl/VisualPaddingListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/swingdsl/VisualPaddingListener.java @@ -30,6 +30,10 @@ import com.github.weisj.darklaf.util.Types; public class VisualPaddingListener implements PropertyChangeListener { + public VisualPaddingListener(final JComponent c) { + VisualPaddingUtil.updateProperty(c); + } + @Override public void propertyChange(final PropertyChangeEvent evt) { if (PropertyKey.BORDER.equals(evt.getPropertyName())) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java index f0e9906c..195bd235 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java @@ -152,7 +152,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants { super.installListeners(b); keyboardActions = new ToggleButtonFocusNavigationActions(b); keyboardActions.installActions(); - visualPaddingListener = new VisualPaddingListener(); + visualPaddingListener = new VisualPaddingListener(b); b.addPropertyChangeListener(visualPaddingListener); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java index 0d7ce1be..0dca25c8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxUI.java @@ -112,7 +112,7 @@ public class DarkComboBoxUI extends BasicComboBoxUI implements ComboBoxConstants comboBoxListener = createComboBoxListener(); comboBox.addMouseListener(comboBoxListener); comboBox.addPropertyChangeListener(comboBoxListener); - visualPaddingListener = new VisualPaddingListener(); + visualPaddingListener = new VisualPaddingListener(comboBox); comboBox.addPropertyChangeListener(visualPaddingListener); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java index 8fb4479e..9fa3c471 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java @@ -97,7 +97,7 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements SpinnerConstants { super.installListeners(); spinnerListener = createSpinnerListener(); spinnerListener.install(); - visualPaddingListener = new VisualPaddingListener(); + visualPaddingListener = new VisualPaddingListener(spinner); spinner.addPropertyChangeListener(visualPaddingListener); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java index e6c6e9d1..c8c4ea60 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java @@ -190,7 +190,7 @@ public abstract class DarkTextUI extends BasicTextUI implements OpacityBufferedU textListener = createTextListener(); editor.addFocusListener(textListener); editor.addPropertyChangeListener(textListener); - visualPaddingListener = new VisualPaddingListener(); + visualPaddingListener = new VisualPaddingListener(editor); editor.addPropertyChangeListener(visualPaddingListener); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java index bf913347..cc04b227 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java @@ -96,7 +96,7 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha button.addPropertyChangeListener(this); keyboardAction = new ToggleButtonFocusNavigationActions(button); keyboardAction.installActions(); - visualPaddingListener = new VisualPaddingListener(); + visualPaddingListener = new VisualPaddingListener(button); button.addPropertyChangeListener(visualPaddingListener); }