From 2e3e443d9cb8733028c315161381b0834e65696e Mon Sep 17 00:00:00 2001 From: weisj Date: Wed, 8 Jul 2020 08:53:44 +0200 Subject: [PATCH] Remove unnecessary flag. --- .../com/github/weisj/darklaf/components/CloseButton.java | 2 +- .../com/github/weisj/darklaf/ui/button/ButtonConstants.java | 5 ----- .../com/github/weisj/darklaf/ui/button/DarkButtonUI.java | 1 - .../weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java | 3 +-- core/src/test/java/ui/button/AbstractButtonDemo.java | 6 +++--- .../weisj/darklaf/platform/windows/ui/WindowsTitlePane.java | 2 +- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/components/CloseButton.java b/core/src/main/java/com/github/weisj/darklaf/components/CloseButton.java index 9ae913dd..75d303e2 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/CloseButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/CloseButton.java @@ -31,13 +31,13 @@ import com.github.weisj.darklaf.ui.button.DarkButtonUI; class CloseButton extends JButton { protected CloseButton() { - putClientProperty(DarkButtonUI.KEY_NO_BACKGROUND, true); putClientProperty(DarkButtonUI.KEY_NO_BORDERLESS_OVERWRITE, true); putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_BORDERLESS_RECTANGULAR); putClientProperty(DarkButtonUI.KEY_THIN, true); setOpaque(false); setRolloverEnabled(true); setBorderPainted(false); + setContentAreaFilled(false); setIcon(UIManager.getIcon("CloseButton.closeIcon")); setDisabledIcon(UIManager.getIcon("CloseButton.closeDisabledIcon")); setRolloverIcon(UIManager.getIcon("CloseButton.closeHoverIcon")); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java b/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java index b15b7307..aa599a64 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/button/ButtonConstants.java @@ -42,7 +42,6 @@ public interface ButtonConstants { String KEY_NO_BORDERLESS_OVERWRITE = "JButton.noBorderlessOverwrite"; String KEY_CORNER = "JButton.cornerFlag"; String KEY_ROUND = "JButton.round"; - String KEY_NO_BACKGROUND = "JButton.noBackground"; String KEY_LEFT_NEIGHBOUR = "JButton.leftNeighbour"; String KEY_RIGHT_NEIGHBOUR = "JButton.rightNeighbour"; @@ -129,8 +128,4 @@ public interface ButtonConstants { static JComponent getNeighbour(final String key, final Component comp) { return PropertyUtil.getObject(comp, key, JComponent.class); } - - static boolean isNoBackground(final AbstractButton b) { - return PropertyUtil.getBooleanProperty(b, KEY_NO_BACKGROUND); - } } 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 8f1b060d..36dc760f 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 @@ -286,7 +286,6 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants { } protected boolean shouldDrawBackground(final AbstractButton c) { - if (ButtonConstants.isNoBackground(c)) return false; Border border = c.getBorder(); return c.isEnabled() && border != null && button.isContentAreaFilled(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java index 7db8494a..0a944673 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/splitpane/DarkSplitPaneDivider.java @@ -31,7 +31,6 @@ import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicSplitPaneDivider; import com.github.weisj.darklaf.icons.EmptyIcon; -import com.github.weisj.darklaf.ui.button.DarkButtonUI; /** * @author Jannis Weis @@ -122,7 +121,7 @@ public class DarkSplitPaneDivider extends BasicSplitPaneDivider { protected OneTouchButton() { setMinimumSize(new Dimension(ONE_TOUCH_SIZE, ONE_TOUCH_SIZE)); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - putClientProperty(DarkButtonUI.KEY_NO_BACKGROUND, true); + setContentAreaFilled(false); setRequestFocusEnabled(false); setBorderPainted(false); setFocusPainted(false); diff --git a/core/src/test/java/ui/button/AbstractButtonDemo.java b/core/src/test/java/ui/button/AbstractButtonDemo.java index 629c4feb..7646d343 100644 --- a/core/src/test/java/ui/button/AbstractButtonDemo.java +++ b/core/src/test/java/ui/button/AbstractButtonDemo.java @@ -100,10 +100,10 @@ public abstract class AbstractButtonDemo implements Co addActionListener(e -> button.putClientProperty(DarkButtonUI.KEY_ALT_ARC, isSelected())); } }); - controlPanel.add(new JCheckBox(DarkButtonUI.KEY_NO_BACKGROUND) { + controlPanel.add(new JCheckBox("Content area filled") { { - setSelected(false); - addActionListener(e -> button.putClientProperty(DarkButtonUI.KEY_NO_BACKGROUND, isSelected())); + setSelected(button.isContentAreaFilled()); + addActionListener(e -> button.setContentAreaFilled(isSelected())); } }); controlPanel.add(new JCheckBox("Button.defaultButtonFollowsFocus") { diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java index e83baa6b..669eb131 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java @@ -389,12 +389,12 @@ public class WindowsTitlePane extends CustomTitlePane { windowIconButton = new JButton(); windowIconButton.putClientProperty("JButton.noShadowOverwrite", true); windowIconButton.setComponentPopupMenu(createMenu()); - windowIconButton.putClientProperty("JButton.noBackground", true); windowIconButton.addActionListener(e -> windowIconButton.getComponentPopupMenu() .show(windowIconButton, windowIconButton.getWidth() / 2, windowIconButton.getHeight() / 2)); windowIconButton.setFocusable(false); + windowIconButton.setContentAreaFilled(false); windowIconButton.setBorderPainted(false); return windowIconButton; }