Browse Source

Make armed state of a button visible for default and regular buttons

Previously armed was painted only for rollover buttons
pull/44/head
Vladimir Sitnikov 5 years ago
parent
commit
aa6f3ce559
  1. 2
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  2. 9
      core/src/test/java/ui/button/ButtonDemo.java

2
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

@ -229,7 +229,7 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
boolean defaultButton = isDefaultButton(c); boolean defaultButton = isDefaultButton(c);
boolean rollOver = (c instanceof JButton && (((JButton) c).isRolloverEnabled() boolean rollOver = (c instanceof JButton && (((JButton) c).isRolloverEnabled()
&& (((JButton) c).getModel().isRollover()))); && (((JButton) c).getModel().isRollover())));
boolean clicked = rollOver && ((JButton) c).getModel().isArmed(); boolean clicked = c instanceof JButton && ((JButton) c).getModel().isArmed();
if (c.isEnabled()) { if (c.isEnabled()) {
if (defaultButton) { if (defaultButton) {
if (clicked) { if (clicked) {

9
core/src/test/java/ui/button/ButtonDemo.java

@ -43,7 +43,7 @@ public class ButtonDemo implements ComponentDemo {
JButton button = new JButton("Test Button", icon); JButton button = new JButton("Test Button", icon);
DemoPanel panel = new DemoPanel(button); DemoPanel panel = new DemoPanel(button);
JPanel controlPanel = panel.getControls(); JPanel controlPanel = panel.getControls();
controlPanel.setLayout(new GridLayout(5, 2)); controlPanel.setLayout(new GridLayout(6, 2));
controlPanel.add(new JCheckBox("enabled") {{ controlPanel.add(new JCheckBox("enabled") {{
setSelected(button.isEnabled()); setSelected(button.isEnabled());
addActionListener(e -> button.setEnabled(isSelected())); addActionListener(e -> button.setEnabled(isSelected()));
@ -96,6 +96,13 @@ public class ButtonDemo implements ComponentDemo {
(b, c) -> button.putClientProperty("JButton.shadow.hover", b ? c : null))); (b, c) -> button.putClientProperty("JButton.shadow.hover", b ? c : null)));
controlPanel.add(new QuickColorChooser("JButton.shadow.click", Color.BLACK, controlPanel.add(new QuickColorChooser("JButton.shadow.click", Color.BLACK,
(b, c) -> button.putClientProperty("JButton.shadow.click", b ? c : null))); (b, c) -> button.putClientProperty("JButton.shadow.click", b ? c : null)));
controlPanel.add(new JCheckBox("defaultButtonFollowsFocus") {{
setSelected(true);
addActionListener(e -> {
UIManager.put("Button.defaultButtonFollowsFocus", isSelected());
button.getRootPane().setDefaultButton(null);
});
}});
return panel; return panel;
} }

Loading…
Cancel
Save