Java JTextField Number getNum(JTextField txt, double defaultNum)

Here you can find the source of getNum(JTextField txt, double defaultNum)

Description

get Num

License

Academic Free License

Declaration

public static double getNum(JTextField txt, double defaultNum) 

Method Source Code

//package com.java2s;
//License from project: Academic Free License 

import javax.swing.JTextField;

public class Main {
    public static double getNum(JTextField txt) {
        return getNum(txt, 0);
    }//from   ww w . jav a2 s  . c  om

    public static double getNum(JTextField txt, double defaultNum) {
        double num = defaultNum;

        try {
            String str = txt.getText().trim();
            num = Double.parseDouble(str);
        } catch (Exception ex) {
            //ex.printStackTrace();
        }

        return num;
    }
}

Related

  1. format(JTextField txt, double num, String fmt)
  2. getNumber(JTextField field, Integer defaultInt)
  3. largeEqualThan(javax.swing.JTextField input, double x)
  4. parseIntFromField(JTextField jField, int pDefault)
  5. placeDoubleTextInField(JTextField inField, int length, double toPlace)