|
|
@ -30,6 +30,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver |
|
|
|
private static final int LEN = 13; |
|
|
|
private static final int LEN = 13; |
|
|
|
private static final int WIDTH = 13; |
|
|
|
private static final int WIDTH = 13; |
|
|
|
private static final int HEIGHT = 10; |
|
|
|
private static final int HEIGHT = 10; |
|
|
|
|
|
|
|
private static final int DEFAULT_NUMBERFIELD_COLUMNS = 2; |
|
|
|
private UINumberField textField; |
|
|
|
private UINumberField textField; |
|
|
|
private UIButton preButton; |
|
|
|
private UIButton preButton; |
|
|
|
private UIButton nextButton; |
|
|
|
private UIButton nextButton; |
|
|
@ -40,9 +41,26 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver |
|
|
|
private UIObserverListener uiObserverListener; |
|
|
|
private UIObserverListener uiObserverListener; |
|
|
|
private GlobalNameListener globalNameListener = null; |
|
|
|
private GlobalNameListener globalNameListener = null; |
|
|
|
private boolean lessMinValue = false; |
|
|
|
private boolean lessMinValue = false; |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Spinner内的数字文本框长度 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private int numberFieldColumns; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UISpinner(double minValue, double maxValue, double dierta) { |
|
|
|
public UISpinner(double minValue, double maxValue, double dierta) { |
|
|
|
|
|
|
|
init(minValue, maxValue, dierta); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UISpinner(double minValue, double maxValue, double dierta, double defaultValue) { |
|
|
|
|
|
|
|
init(minValue, maxValue, dierta); |
|
|
|
|
|
|
|
textField.setValue(defaultValue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UISpinner(double minValue, double maxValue, double dierta, int numberFieldColumns) { |
|
|
|
|
|
|
|
this.numberFieldColumns = numberFieldColumns; |
|
|
|
|
|
|
|
init(minValue, maxValue, dierta); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void init(double minValue, double maxValue, double dierta) { |
|
|
|
this.minValue = minValue; |
|
|
|
this.minValue = minValue; |
|
|
|
this.maxValue = maxValue; |
|
|
|
this.maxValue = maxValue; |
|
|
|
this.dierta = dierta; |
|
|
|
this.dierta = dierta; |
|
|
@ -50,11 +68,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver |
|
|
|
iniListener(); |
|
|
|
iniListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public UISpinner(double minValue, double maxValue, double dierta, double defaultValue) { |
|
|
|
|
|
|
|
this(minValue, maxValue, dierta); |
|
|
|
|
|
|
|
textField.setValue(defaultValue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void iniListener() { |
|
|
|
private void iniListener() { |
|
|
|
if (shouldResponseChangeListener()) { |
|
|
|
if (shouldResponseChangeListener()) { |
|
|
|
this.addChangeListener(new ChangeListener() { |
|
|
|
this.addChangeListener(new ChangeListener() { |
|
|
@ -308,7 +321,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected UINumberField initNumberField() { |
|
|
|
protected UINumberField initNumberField() { |
|
|
|
return new UINumberField(2) { |
|
|
|
int columns = this.numberFieldColumns == 0 ? DEFAULT_NUMBERFIELD_COLUMNS : this.numberFieldColumns; |
|
|
|
|
|
|
|
return new UINumberField(columns) { |
|
|
|
public boolean shouldResponseChangeListener() { |
|
|
|
public boolean shouldResponseChangeListener() { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|