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 d19693e5..e7a4ac88 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 @@ -122,7 +122,6 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g); int mnemonicIndex = button.getDisplayedMnemonicIndex(); if (!model.isEnabled()) { - g.setColor(inactiveForeground); mnemonicIndex = -1; } SwingUtilities2.drawStringUnderlineCharAt(c, g, text, mnemonicIndex, @@ -149,6 +148,9 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene if (fg instanceof UIResource && isDefaultButton(button) && !isShadowVariant(button)) { fg = defaultForeground; } + if (fg instanceof UIResource && !button.getModel().isEnabled()) { + fg = inactiveForeground; + } return fg; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkToggleButtonUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkToggleButtonUI.java index adec58c8..2f5a0a4c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkToggleButtonUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/DarkToggleButtonUI.java @@ -31,6 +31,7 @@ import sun.swing.SwingUtilities2; import javax.swing.*; import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.UIResource; import java.awt.*; import java.awt.geom.RoundRectangle2D; import java.beans.PropertyChangeListener; @@ -77,6 +78,7 @@ public class DarkToggleButtonUI extends DarkButtonUI { protected Color inactiveSliderColor; protected Color sliderBorderColor; protected Color inactiveSliderBorderColor; + protected Color selectedForeground; public static ComponentUI createUI(final JComponent c) { @@ -96,6 +98,7 @@ public class DarkToggleButtonUI extends DarkButtonUI { inactiveSliderColor = UIManager.getColor("ToggleButton.disabledSliderKnobFillColor"); sliderBorderColor = UIManager.getColor("ToggleButton.sliderKnobBorderColor"); inactiveSliderBorderColor = UIManager.getColor("ToggleButton.disabledSliderKnobBorderColor"); + selectedForeground = UIManager.getColor("ToggleButton.selectedForeground"); } @Override @@ -115,6 +118,14 @@ public class DarkToggleButtonUI extends DarkButtonUI { } } + @Override + protected Color getForeground(final AbstractButton button) { + if (button.isSelected() && !isSlider(button) && button.getForeground() instanceof UIResource) { + return selectedForeground; + } + return super.getForeground(button); + } + protected Color getBackgroundColor(final JComponent c) { AbstractButton b = (AbstractButton) c; boolean rollOver = (b.isRolloverEnabled() || doConvertToShadow(b)) && (((JButton) c).getModel().isRollover()); diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toggleButton.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toggleButton.properties index 5c7ac71b..6a3f45bf 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toggleButton.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/toggleButton.properties @@ -31,6 +31,7 @@ ToggleButton.sliderKnobFillColor = %controlFill ToggleButton.sliderKnobBorderColor = %controlBorder ToggleButton.disabledSliderKnobFillColor = %controlFillDisabled ToggleButton.disabledSliderKnobBorderColor = %controlFillDisabled +ToggleButton.selectedForeground = %textContrastForeground ToggleButton.inactiveFillColor = %widgetFill ToggleButton.activeFillColor = %textForegroundInactive