From 050d6b520d9262f098d8d6e373fb74b44e01987a Mon Sep 17 00:00:00 2001 From: weisj Date: Sat, 4 Apr 2020 16:57:46 +0200 Subject: [PATCH] Fixed Tristate model not installed when updating state icon. --- .../radiobutton/DarkRadioButtonMenuItemUI.java | 13 ++++--------- .../tristate/DarkTristateCheckBoxMenuItemUI.java | 7 +++++++ .../weisj/darklaf/properties/ui/menuItem.properties | 5 ++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java index 41769877..a43417aa 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonMenuItemUI.java @@ -55,19 +55,14 @@ public class DarkRadioButtonMenuItemUI extends DarkMenuItemUIBase implements Tog return "RadioButtonMenuItem"; } - @Override - public void installUI(final JComponent c) { - super.installUI(c); - acceleratorFont = UIManager.getFont("MenuItem.font"); - acceleratorForeground = UIManager.getColor("MenuItem.foreground"); - acceleratorSelectionForeground = UIManager.getColor("MenuItem.selectionForeground"); - c.putClientProperty(KEY_NO_NOT_CLOSE_ON_CLICK, UIManager.getBoolean(KEY_NO_NOT_CLOSE_ON_CLICK)); - } - @Override public void installDefaults() { super.installDefaults(); iconBaselineOffset = UIManager.getInt(getPropertyPrefix() + ".iconBaselineOffset"); + acceleratorFont = UIManager.getFont("MenuItem.font"); + acceleratorForeground = UIManager.getColor("MenuItem.foreground"); + acceleratorSelectionForeground = UIManager.getColor("MenuItem.selectionForeground"); + menuItem.putClientProperty(KEY_NO_NOT_CLOSE_ON_CLICK, UIManager.getBoolean(KEY_NO_NOT_CLOSE_ON_CLICK)); installIcons(); checkIcon = getStateIcon(menuItem); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxMenuItemUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxMenuItemUI.java index 3a641c91..d9d2d913 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxMenuItemUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/tristate/DarkTristateCheckBoxMenuItemUI.java @@ -23,6 +23,7 @@ */ package com.github.weisj.darklaf.ui.togglebutton.tristate; +import com.github.weisj.darklaf.components.tristate.TristateButtonModel; import com.github.weisj.darklaf.components.tristate.TristateCheckBoxMenuItem; import com.github.weisj.darklaf.components.tristate.TristateState; import com.github.weisj.darklaf.ui.togglebutton.checkbox.DarkCheckBoxMenuItemUI; @@ -42,6 +43,12 @@ public class DarkTristateCheckBoxMenuItemUI extends DarkCheckBoxMenuItemUI { return new DarkTristateCheckBoxMenuItemUI(); } + @Override + public void installDefaults() { + menuItem.setModel(new TristateButtonModel()); + super.installDefaults(); + } + @Override protected void installIcons() { super.installIcons(); diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties index 8b890787..9c04076e 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties @@ -38,8 +38,6 @@ RadioButtonMenuItem.acceleratorForeground = %acceleratorForeground RadioButtonMenuItem.acceleratorSelectionForeground = %acceleratorForeground RadioButtonMenuItem.selectionBackground = %highlightFillFocus RadioButtonMenuItem.doNotCloseOnMouseClick = true -RadioButtonMenuItem.iconBaselineOffset = 0 - CheckBoxMenuItemUI = com.github.weisj.darklaf.ui.togglebutton.checkbox.DarkCheckBoxMenuItemUI CheckBoxMenuItem.border = com.github.weisj.darklaf.ui.menu.DarkMenuItemBorder @@ -49,7 +47,6 @@ CheckBoxMenuItem.acceleratorSelectionForeground = %acceleratorForeground CheckBoxMenuItem.selectionBackground = %highlightFillFocus CheckBoxMenuItem.foreground = %textForeground CheckBoxMenuItem.doNotCloseOnMouseClick = true -CheckBoxMenuItem.iconBaselineOffset = 0 Menu.afterCheckIconGap = 2 @@ -69,12 +66,14 @@ CheckBoxMenuItem.iconTextGap = 2 CheckBoxMenuItem.checkIconOffset = 2 CheckBoxMenuItem.minimumTextOffset = 16 CheckBoxMenuItem.acceleratorTextOffset = 10 +CheckBoxMenuItem.iconBaselineOffset = 0 RadioButtonMenuItem.afterCheckIconGap = 2 RadioButtonMenuItem.iconTextGap = 2 RadioButtonMenuItem.checkIconOffset = 2 RadioButtonMenuItem.minimumTextOffset = 16 RadioButtonMenuItem.acceleratorTextOffset = 10 +RadioButtonMenuItem.iconBaselineOffset = 0 #Icons Menu.arrowIcon = navigation/arrowRight.svg[themed]