/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package usda.weru.weps;

/**
 *
 * @author jcgao
 */
import javax.swing.*;

public class DoubleInputVerifier extends InputVerifier {

    @Override
    public boolean verify(JComponent input) {
        JTextField tf = (JTextField) input;
        try 
        { 
            Double d = Double.valueOf(tf.getText());
            if (d >= 0) {
                return true;
            } else {
                JOptionPane.showMessageDialog(null, "Invalid value! Input value cannot be negative!");
                return false;
            }
        }
        catch(NumberFormatException nfe)
        {
           JOptionPane.showMessageDialog(null, "Invalid value.  The Water Erosion field must contain a number.");
            return false;
        }
    }
}
