Java examples for Swing:JFormattedTextField
Have field to format a number in $#0,000.00 format for JFormattedTextField
import java.text.DecimalFormat; import java.text.NumberFormat; import javax.swing.JFormattedTextField; import javax.swing.text.NumberFormatter; public class Main { public static void main(String[] args) { NumberFormat numFormat = new DecimalFormat("$#0,000.00"); NumberFormatter numFormatter = new NumberFormatter(numFormat); JFormattedTextField dobField = new JFormattedTextField(); dobField = new JFormattedTextField(numFormatter); }/* www.j a v a 2s . c o m*/ }