1 33 34 package com.nqadmin.swingSet.formatting; 35 36 import java.util.Locale ; 37 import javax.swing.JTextField ; 38 39 43 44 public class SSCurrencyField extends SSFormattedTextField { 45 46 private int precision = 1; 47 private int decimals = 0; 48 49 52 private int minimumIntegerDigits; 53 54 55 public SSCurrencyField() { 56 this(new SSCurrencyFormatterFactory()); 57 } 58 59 public SSCurrencyField(int precision, int decimals) { 60 this(new SSCurrencyFormatterFactory(precision, decimals)); 61 } 62 63 public SSCurrencyField(int precision, int decimals, Locale editor, Locale display) { 64 this(new SSCurrencyFormatterFactory(precision, decimals, editor, display)); 65 } 66 67 public SSCurrencyField(javax.swing.JFormattedTextField.AbstractFormatterFactory factory) { 68 super(factory); 69 this.setHorizontalAlignment(JTextField.RIGHT); 70 this.setValue(new java.lang.Double (0.00)); 71 } 72 73 77 public int getPrecision() { 78 return precision; 79 } 80 81 85 public int getDecimals() { 86 return decimals; 87 } 88 89 public void setPrecision(int precision) { 90 this.precision = precision; 91 this.setFormatterFactory(new SSCurrencyFormatterFactory(precision, decimals)); 92 } 93 94 public void setDecimals(int decimals) { 95 this.decimals = decimals; 96 this.setFormatterFactory(new SSCurrencyFormatterFactory(precision, decimals)); 97 } 98 } 99 100 115 | Popular Tags |