Java JTextField Number within(javax.swing.JTextField input, double low, double high, Vector errMsgList, String errMsg)

Here you can find the source of within(javax.swing.JTextField input, double low, double high, Vector errMsgList, String errMsg)

Description

Check if the JTextField input is larger than x

License

Open Source License

Parameter

Parameter Description
input the JTextField object
x parameter x

Return

true or false

Declaration

public static boolean within(javax.swing.JTextField input, double low, double high, Vector<String> errMsgList,
        String errMsg) throws Exception 

Method Source Code


//package com.java2s;
/*/*  ww w .j a v a  2 s . c  om*/
 * @(#)VerifyUtil.java   
 *
 * Copyright (C) 2006 www.interpss.com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * @Author Mike Zhou
 * @Version 1.0
 * @Date 09/15/2006
 * 
 *   Revision History
 *   ================
 *
 */

import java.util.Vector;

public class Main {
    /**
     * Check if the JTextField input is larger than x
     * 
     * @param input the JTextField object
     * @param x  parameter x
     * @return true or false
     */
    public static boolean within(javax.swing.JTextField input, double low, double high) throws Exception {
        double d = new Double(input.getText()).doubleValue();
        if (d >= low && d <= high)
            return true;
        return false;
    }

    /**
     * Check if the JTextField input is larger than x
     * 
     * @param input  the JTextField object
     * @param x  parameter x
     * @return true or false
     */
    public static boolean within(javax.swing.JTextField input, double low, double high, Vector<String> errMsgList,
            String errMsg) throws Exception {
        boolean ok = within(input, low, high);
        if (!ok)
            errMsgList.add(errMsg);
        return ok;
    }
}

Related

  1. setNumericAndCharOnly(final javax.swing.JTextField textField)
  2. setTextField(javax.swing.JTextField textField, double value, int precision)
  3. showInDecimalFormat(JTextField pJTextField)
  4. validateDoubleInput(Component parentComponent, JLabel label, JTextField textField, String valueDescription, String errorTitle, boolean positiveValue, boolean showMessage, boolean valid)
  5. verifyNumber_geq(JTextField field, Long number)