Here you can find the source of placeDoubleTextInField(JTextField inField, int length, double toPlace)
public static void placeDoubleTextInField(JTextField inField, int length, double toPlace)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import javax.swing.JTextField; public class Main { public static void placeDoubleTextInField(JTextField inField, int length, double toPlace) { char[] valArray = Double.toString(toPlace).toCharArray(); inField.setText(new String(Arrays.copyOf(valArray, Math.min(valArray.length, length)))); }// w w w . j ava2 s . c om }