|
|
|
@ -58,7 +58,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
|
|
|
|
|
* Spinner内的数字文本框长度 |
|
|
|
|
*/ |
|
|
|
|
private int numberFieldColumns; |
|
|
|
|
private boolean hasTextFieldFocus = false; |
|
|
|
|
private boolean textFieldFocus = false; |
|
|
|
|
|
|
|
|
|
public UISpinner() { |
|
|
|
|
|
|
|
|
@ -197,6 +197,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
|
|
|
|
|
this.nextButton.setEnabled(flag); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setTextFieldFocus(boolean textFieldFocus) { |
|
|
|
|
this.textFieldFocus = textFieldFocus; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
Dimension dim = super.getPreferredSize(); |
|
|
|
@ -319,7 +323,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void mouseWheelMoved(MouseWheelEvent e) { |
|
|
|
|
if (hasTextFieldFocus && isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { |
|
|
|
|
if (textFieldFocus && isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { |
|
|
|
|
setValue(value - e.getWheelRotation()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -333,12 +337,12 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
|
|
|
|
|
textField.addFocusListener(new FocusAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
|
hasTextFieldFocus = true; |
|
|
|
|
textFieldFocus = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
|
hasTextFieldFocus = false; |
|
|
|
|
textFieldFocus = false; |
|
|
|
|
textField.getDocument().removeDocumentListener(docListener); |
|
|
|
|
textField.setValue(value); |
|
|
|
|
textField.getDocument().addDocumentListener(docListener); |
|
|
|
|