Browse Source

Fixed NPE on Laf change in spinner ui.

pull/127/head
weisj 5 years ago
parent
commit
9b3c97398b
  1. 7
      core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java

7
core/src/main/java/com/github/weisj/darklaf/ui/spinner/DarkSpinnerUI.java

@ -111,6 +111,9 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe
@Override @Override
protected void uninstallListeners() { protected void uninstallListeners() {
super.uninstallListeners(); super.uninstallListeners();
if (editor != null && editor.getComponents().length > 0) {
editor.getComponents()[0].removeFocusListener(focusListener);
}
spinner.removeMouseListener(mouseListener); spinner.removeMouseListener(mouseListener);
spinner.removePropertyChangeListener(this); spinner.removePropertyChangeListener(this);
} }
@ -185,6 +188,10 @@ public class DarkSpinnerUI extends BasicSpinnerUI implements PropertyChangeListe
if (oldEditor != null && oldEditor.getComponents().length > 0) { if (oldEditor != null && oldEditor.getComponents().length > 0) {
oldEditor.getComponents()[0].removeFocusListener(focusListener); oldEditor.getComponents()[0].removeFocusListener(focusListener);
} }
editor = newEditor;
if (oldEditor != null && oldEditor.getComponents().length > 0) {
oldEditor.getComponents()[0].removeFocusListener(focusListener);
}
if (newEditor != null && newEditor.getComponents().length > 0) { if (newEditor != null && newEditor.getComponents().length > 0) {
Component comp = newEditor.getComponents()[0]; Component comp = newEditor.getComponents()[0];
comp.addFocusListener(focusListener); comp.addFocusListener(focusListener);

Loading…
Cancel
Save