Browse Source

Added focusable as condition for converting to shadow variant.

pull/97/head
weisj 5 years ago
parent
commit
fd5e3636a3
  1. 46
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonListener.java
  2. 2
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

46
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonListener.java

@ -50,50 +50,4 @@ public class DarkButtonListener extends BasicButtonListener {
model.setRollover(false);
model.setArmed(false);
}
//A possible fix for shadow buttons being focusable.
//
// public static void loadActionMap(final LazyActionMap map) {
// map.put(new Actions(Actions.PRESS));
// map.put(new Actions(Actions.RELEASE));
// }
//
//
// /**
// * Actions for Buttons. Two types of action are supported:
// * pressed: Moves the button to a pressed state
// * released: Disarms the button.
// */
// protected static class Actions extends UIAction {
// private static final String PRESS = "pressed";
// private static final String RELEASE = "released";
//
// protected Actions(final String name) {
// super(name);
// }
//
// public void actionPerformed(final ActionEvent e) {
// AbstractButton b = (AbstractButton)e.getSource();
// if (DarkButtonUI.doConvertToShadow(b) || DarkButtonUI.isShadowVariant(b)) return;
// String key = getName();
// if (PRESS.equals(key)) {
// ButtonModel model = b.getModel();
// model.setArmed(true);
// model.setPressed(true);
// if(!b.hasFocus()) {
// b.requestFocus();
// }
// }
// else if (RELEASE.equals(key)) {
// ButtonModel model = b.getModel();
// model.setPressed(false);
// model.setArmed(false);
// }
// }
//
// @Override
// public boolean accept(final Object sender) {
// return !((sender instanceof AbstractButton) &&
// !((AbstractButton)sender).getModel().isEnabled());
// }
// }
}

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

@ -236,7 +236,7 @@ public class DarkButtonUI extends BasicButtonUI implements PropertyChangeListene
}
protected static boolean doConvertToShadow(final AbstractButton b) {
return isIconOnly(b) && convertIconButtonToShadow(b);
return isIconOnly(b) && !b.isFocusable() && convertIconButtonToShadow(b);
}
protected Color getBackgroundColor(final JComponent c) {

Loading…
Cancel
Save