Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.swing.JTextField;

public class Main {
    public static Double getDouble(JTextField txt, Double defaultVal) {
        String str = txt.getText();
        if (str.trim().length() <= 0)
            return defaultVal;

        double val = 0;
        try {
            val = Double.parseDouble(str);
        } catch (NumberFormatException ex) {
        }
        return new Double(val);
    }
}