From d86510be3846f0f1a8a284b9c7c23536f3d32eb3 Mon Sep 17 00:00:00 2001 From: weisj Date: Wed, 8 Jul 2020 09:02:06 +0200 Subject: [PATCH] Allow background painting if no border is painted. --- .../github/weisj/darklaf/ui/button/DarkButtonUI.java | 4 +--- core/src/test/java/ui/button/AbstractButtonDemo.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) 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 36dc760f..3dc1e6f3 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 @@ -28,7 +28,6 @@ import java.awt.*; import java.awt.geom.RoundRectangle2D; import javax.swing.*; -import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicButtonListener; @@ -286,8 +285,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants { } protected boolean shouldDrawBackground(final AbstractButton c) { - Border border = c.getBorder(); - return c.isEnabled() && border != null && button.isContentAreaFilled(); + return button.isContentAreaFilled(); } protected int getArc(final Component c) { diff --git a/core/src/test/java/ui/button/AbstractButtonDemo.java b/core/src/test/java/ui/button/AbstractButtonDemo.java index 7646d343..e60e549a 100644 --- a/core/src/test/java/ui/button/AbstractButtonDemo.java +++ b/core/src/test/java/ui/button/AbstractButtonDemo.java @@ -106,6 +106,18 @@ public abstract class AbstractButtonDemo implements Co addActionListener(e -> button.setContentAreaFilled(isSelected())); } }); + controlPanel.add(new JCheckBox("Border painted") { + { + setSelected(button.isBorderPainted()); + addActionListener(e -> button.setBorderPainted(isSelected())); + } + }); + controlPanel.add(new JCheckBox("Focus Painted") { + { + setSelected(button.isFocusPainted()); + addActionListener(e -> button.setFocusPainted(isSelected())); + } + }); controlPanel.add(new JCheckBox("Button.defaultButtonFollowsFocus") { { setSelected(UIManager.getBoolean("Button.defaultButtonFollowsFocus"));