Here you can find the source of format(JTextField txt, double num, String fmt)
public static void format(JTextField txt, double num, String fmt)
//package com.java2s; //License from project: Academic Free License import java.text.DecimalFormat; import javax.swing.JTextField; public class Main { public static void format(JTextField txt, double num, String fmt) { DecimalFormat df = new DecimalFormat(fmt); txt.setText(df.format(num));// w w w . ja v a 2s . c o m } }