Java JTextField Number format(JTextField txt, double num, String fmt)

Here you can find the source of format(JTextField txt, double num, String fmt)

Description

format

License

Academic Free License

Declaration

public static void format(JTextField txt, double num, String fmt) 

Method Source Code

//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
    }
}

Related

  1. getNum(JTextField txt, double defaultNum)
  2. getNumber(JTextField field, Integer defaultInt)
  3. largeEqualThan(javax.swing.JTextField input, double x)
  4. parseIntFromField(JTextField jField, int pDefault)