|
|
|
@ -58,6 +58,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
|
|
|
|
|
* Spinner内的数字文本框长度 |
|
|
|
|
*/ |
|
|
|
|
private int numberFieldColumns; |
|
|
|
|
private boolean hasTextFieldFocus = false; |
|
|
|
|
|
|
|
|
|
public UISpinner() { |
|
|
|
|
|
|
|
|
@ -318,7 +319,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void mouseWheelMoved(MouseWheelEvent e) { |
|
|
|
|
if (isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { |
|
|
|
|
if (hasTextFieldFocus && isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { |
|
|
|
|
setValue(value - e.getWheelRotation()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -330,8 +331,14 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
|
|
|
|
|
textField.getDocument().removeDocumentListener(docListener); |
|
|
|
|
textField.getDocument().addDocumentListener(docListener); |
|
|
|
|
textField.addFocusListener(new FocusAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
|
hasTextFieldFocus = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
|
hasTextFieldFocus = false; |
|
|
|
|
textField.getDocument().removeDocumentListener(docListener); |
|
|
|
|
textField.setValue(value); |
|
|
|
|
textField.getDocument().addDocumentListener(docListener); |
|
|
|
|