1 33 34 package com.nqadmin.swingSet.formatting; 35 36 import java.text.NumberFormat ; 37 import javax.swing.text.NumberFormatter ; 38 import java.util.Locale ; 39 import javax.swing.JTextField ; 40 41 42 46 47 public class SSIntegerField extends SSFormattedTextField { 48 49 private int precision = 1; 50 51 54 private int minimumIntegerDigits; 55 56 57 public SSIntegerField() { 58 this(new SSIntegerFormatterFactory()); 59 } 60 61 public SSIntegerField(int precision) { 62 this(new SSIntegerFormatterFactory(precision)); 63 } 64 65 public SSIntegerField(javax.swing.JFormattedTextField.AbstractFormatterFactory factory) { 66 super(factory); 67 this.setHorizontalAlignment(JTextField.RIGHT); 68 } 69 70 public int getPrecision() { 71 return precision; 72 } 73 74 public void setPrecision(int precision) { 75 this.precision = precision; 76 this.setFormatterFactory(new SSIntegerFormatterFactory(precision)); 77 } 78 79 80 84 public int getMinimumIntegerDigits() { 85 86 return this.minimumIntegerDigits; 87 } 88 89 93 public void setMinimumIntegerDigits(int minimumIntegerDigits) { 94 95 this.minimumIntegerDigits = minimumIntegerDigits; 96 } 97 } 98 99 114 | Popular Tags |