Browse Source

Allow background painting if no border is painted.

pull/198/head
weisj 4 years ago
parent
commit
d86510be38
  1. 4
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  2. 12
      core/src/test/java/ui/button/AbstractButtonDemo.java

4
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 java.awt.geom.RoundRectangle2D;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicButtonListener; import javax.swing.plaf.basic.BasicButtonListener;
@ -286,8 +285,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
} }
protected boolean shouldDrawBackground(final AbstractButton c) { protected boolean shouldDrawBackground(final AbstractButton c) {
Border border = c.getBorder(); return button.isContentAreaFilled();
return c.isEnabled() && border != null && button.isContentAreaFilled();
} }
protected int getArc(final Component c) { protected int getArc(final Component c) {

12
core/src/test/java/ui/button/AbstractButtonDemo.java

@ -106,6 +106,18 @@ public abstract class AbstractButtonDemo<T extends AbstractButton> implements Co
addActionListener(e -> button.setContentAreaFilled(isSelected())); 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") { controlPanel.add(new JCheckBox("Button.defaultButtonFollowsFocus") {
{ {
setSelected(UIManager.getBoolean("Button.defaultButtonFollowsFocus")); setSelected(UIManager.getBoolean("Button.defaultButtonFollowsFocus"));

Loading…
Cancel
Save