Here you can find the source of setTextField(javax.swing.JTextField textField, double value, int precision)
public static void setTextField(javax.swing.JTextField textField, double value, int precision)
//package com.java2s; //License from project: Open Source License public class Main { /** /*from w w w. ja va 2 s. c o m*/ * Set a text field with the given value using a precision of 10. */ public static void setTextField(javax.swing.JTextField textField, double value) { int precision = 10; java.text.NumberFormat nf = java.text.NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(precision); nf.setMinimumFractionDigits(precision); nf.setGroupingUsed(false); textField.setText(nf.format(value)); textField.setCaretPosition(0); } /** * Set a text field with the given value using the given precision. */ public static void setTextField(javax.swing.JTextField textField, double value, int precision) { java.text.NumberFormat nf = java.text.NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(precision); nf.setMinimumFractionDigits(precision); nf.setGroupingUsed(false); textField.setText(nf.format(value)); textField.setCaretPosition(0); } }