1 33 34 package com.nqadmin.swingSet.formatting; 35 36 import javax.swing.text.NumberFormatter ; 37 import java.text.NumberFormat ; 38 import java.util.Locale ; 39 40 import java.io.Serializable ; 41 import java.text.ParseException ; 42 43 47 public class SSIntegerFormatterFactory extends javax.swing.text.DefaultFormatterFactory implements Serializable { 48 49 public SSIntegerFormatterFactory() { 50 this.setDefaultFormatter(new NumberFormatter (NumberFormat.getIntegerInstance())); 51 this.setNullFormatter(null); 52 this.setEditFormatter(new NumberFormatter (NumberFormat.getIntegerInstance(Locale.US))); 53 this.setDisplayFormatter(new NumberFormatter (NumberFormat.getIntegerInstance())); 54 } 55 56 public SSIntegerFormatterFactory(int precision) { 57 NumberFormat nfd = NumberFormat.getIntegerInstance(); 58 59 nfd.setMaximumIntegerDigits(precision); 60 nfd.setMinimumIntegerDigits(1); 61 62 this.setDefaultFormatter(new NumberFormatter (NumberFormat.getIntegerInstance())); 63 this.setNullFormatter(null); 64 this.setEditFormatter(new NumberFormatter (NumberFormat.getIntegerInstance(Locale.US))); 65 this.setDisplayFormatter(new NumberFormatter (nfd)); 66 67 } 68 } 69 70 85 | Popular Tags |