diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java index 1b7ee055..a69bdf1a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerListener.java @@ -32,7 +32,6 @@ import java.beans.PropertyChangeListener; import javax.swing.*; import com.github.weisj.darklaf.util.PropertyKey; -import com.github.weisj.darklaf.util.PropertyUtil; public class DarkSpinnerListener extends MouseAdapter implements PropertyChangeListener, FocusListener, SpinnerConstants { @@ -94,7 +93,7 @@ public class DarkSpinnerListener extends MouseAdapter spinner.revalidate(); spinner.repaint(); } else if (PropertyKey.ENABLED.equals(key)) { - PropertyUtil.installBackground(spinner, spinner.isEnabled() ? ui.background : ui.inactiveBackground); + ui.updateBackground(); } } } 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 f4d602b4..3bbe04fa 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 @@ -35,6 +35,7 @@ import com.github.weisj.darklaf.components.ArrowButton; import com.github.weisj.darklaf.delegate.LayoutManagerDelegate; import com.github.weisj.darklaf.graphics.PaintUtil; import com.github.weisj.darklaf.util.PropertyKey; +import com.github.weisj.darklaf.util.PropertyUtil; /** * @author Konstantin Bulenkov @@ -84,6 +85,7 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements SpinnerConstants { arrowUpInactiveIcon = UIManager.getIcon("Spinner.arrowUpInactive.icon"); minusInactiveIcon = UIManager.getIcon("Spinner.minusInactive.icon"); plusInactiveIcon = UIManager.getIcon("Spinner.plusInactive.icon"); + updateBackground(); LookAndFeel.installProperty(spinner, PropertyKey.OPAQUE, false); } @@ -241,7 +243,6 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements SpinnerConstants { JComponent editor = spinner.getEditor(); if (editorComponent != null) { - // System.out.println(((JComponent) editorComponent).getBorder()); editorComponent.setBackground(getBackground(c)); g.setColor(editorComponent.getBackground()); } else { @@ -282,6 +283,10 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements SpinnerConstants { return c == null ? inactiveBackground : c.getBackground(); } + protected void updateBackground() { + PropertyUtil.installBackground(spinner, spinner.isEnabled() ? background : inactiveBackground); + } + protected Color getArrowBackground(final JComponent c) { return c == null || !c.isEnabled() ? inactiveBackground : arrowBackground; } diff --git a/core/src/test/java/ui/spinner/SpinnerDemo.java b/core/src/test/java/ui/spinner/SpinnerDemo.java index ecaa364a..c87886d7 100644 --- a/core/src/test/java/ui/spinner/SpinnerDemo.java +++ b/core/src/test/java/ui/spinner/SpinnerDemo.java @@ -38,9 +38,15 @@ public class SpinnerDemo implements ComponentDemo { @Override public JComponent createComponent() { - JSpinner spinner = new JSpinner(); - DemoPanel panel = new DemoPanel(spinner); + JSpinner spinner = new JSpinner() { + @Override + public void updateUI() { + super.updateUI(); + ((JFormattedTextField) getEditor().getComponent(0)).setColumns(3); + } + }; + DemoPanel panel = new DemoPanel(spinner); JPanel controlPanel = panel.addControls(1); controlPanel.add(new JCheckBox("enabled") { {