1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
public class IntegerFormattedTextField extends JFormattedTextField {
/**
*
*/
private static final long serialVersionUID = 1L;
private int min;
private int max;
private String textValue = "";
private Object o;
private Enum enumOb;
public IntegerFormattedTextField(RegexFormatter integer_formatter,
JPanel panel, GridBagConstraints gbc, int min, int max, Object o,
Enum enumOb) {
super(integer_formatter);
this.enumOb = enumOb;
this.min = min;
this.max = max;
this.o = o;
textValue = getValueObject();
setForeground(Color.gray);
this.setText(textValue);
this.addKeyListener(new KeyListener() {
...
}
});
panel.add(this, gbc);
}
public IntegerFormattedTextField(JPanel panel, GridBagConstraints gbc,
Object o, Enum enumOb) {
RegexFormatter integer_formatter = new RegexFormatter("\\d{0,10}");
new IntegerFormattedTextField(integer_formatter, panel, gbc,
Integer.MIN_VALUE, Integer.MAX_VALUE, o, enumOb);
} |
Partager