Destiny.Lin
1 year ago
5 changed files with 114 additions and 7 deletions
@ -0,0 +1,59 @@
|
||||
package com.fr.design.mainframe.vcs.ui; |
||||
|
||||
import com.fr.design.editor.editor.IntegerEditor; |
||||
import com.fr.design.gui.itextfield.UIIntNumberField; |
||||
import com.fr.design.gui.itextfield.UINumberField; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
|
||||
import java.awt.event.FocusAdapter; |
||||
import java.awt.event.FocusEvent; |
||||
|
||||
/** |
||||
* 正整数输入框 |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2023/7/25 |
||||
*/ |
||||
public class UIPositiveIntEditor extends IntegerEditor { |
||||
private static final int DEFAULT_COLUMNS = 4; |
||||
|
||||
private static final int MIN = 1; |
||||
private static final int MAX = 99999; |
||||
|
||||
private static final int DEFAULT_VALUE = 60; |
||||
|
||||
public UIPositiveIntEditor(Integer value) { |
||||
super(value); |
||||
numberField.setMaxValue(MAX); |
||||
numberField.setMinValue(MIN); |
||||
initNumberFieldListener(); |
||||
} |
||||
|
||||
public UIPositiveIntEditor(Integer value, Integer min, Integer max) { |
||||
super(value); |
||||
numberField.setMaxValue(max); |
||||
numberField.setMinValue(min); |
||||
initNumberFieldListener(); |
||||
} |
||||
|
||||
private void initNumberFieldListener() { |
||||
numberField.addFocusListener(new FocusAdapter() { |
||||
@Override |
||||
public void focusLost(FocusEvent e) { |
||||
if (StringUtils.isEmpty(numberField.getTextValue())) { |
||||
numberField.setValue(DEFAULT_VALUE); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected UINumberField createNumberField() { |
||||
UIIntNumberField field = new UIIntNumberField(); |
||||
field.setColumns(DEFAULT_COLUMNS); |
||||
return field; |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.mainframe.vcs.ui; |
||||
|
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.gui.itextfield.UIIntNumberField; |
||||
import com.fr.design.gui.itextfield.UINumberField; |
||||
|
||||
/** |
||||
* 只允许输入正整数的Spinner |
||||
* |
||||
* @author Destiny.Lin |
||||
* @since 11.0 |
||||
* Created on 2023/7/25 |
||||
*/ |
||||
public class UIPositiveIntSpinner extends UISpinner { |
||||
private static final int DEFAULT_COLUMNS = 5; |
||||
|
||||
|
||||
public UIPositiveIntSpinner() { |
||||
} |
||||
|
||||
public UIPositiveIntSpinner(double minValue, double maxValue, double dierta) { |
||||
super(minValue, maxValue, dierta); |
||||
} |
||||
|
||||
public UIPositiveIntSpinner(double minValue, double maxValue, double dierta, double defaultValue) { |
||||
super(minValue, maxValue, dierta, defaultValue); |
||||
} |
||||
|
||||
public UIPositiveIntSpinner(double minValue, double maxValue, double dierta, double defaultValue, boolean fillNegativeNumber) { |
||||
super(minValue, maxValue, dierta, defaultValue, fillNegativeNumber); |
||||
} |
||||
|
||||
@Override |
||||
protected UINumberField initNumberField() { |
||||
UIIntNumberField field = new UIIntNumberField(); |
||||
field.setColumns(DEFAULT_COLUMNS); |
||||
return field; |
||||
} |
||||
} |
Loading…
Reference in new issue