Java JTextField isEmptyStr(javax.swing.JTextField input)

Here you can find the source of isEmptyStr(javax.swing.JTextField input)

Description

Check if the JTextField input is empty

License

Open Source License

Parameter

Parameter Description
input the JTextField object

Return

true or false

Declaration

public static boolean isEmptyStr(javax.swing.JTextField input) 

Method Source Code

//package com.java2s;
/*/* w ww.  j  a  v a 2  s.c o m*/
 * @(#)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
 *   ================
 *
 */

public class Main {
    /**
     * Check if the JTextField input is empty
     * 
     * @param input the JTextField object
     * @return true or false
     */
    public static boolean isEmptyStr(javax.swing.JTextField input) {
        return "".equals(input.getText().trim());
    }

    /**
     * Check if the JComboBox selection is empty
     * 
     * @param input the JComboBox object
     * @return true or false
     */
    public static boolean isEmptyStr(javax.swing.JComboBox input) {
        String str = (String) input.getSelectedItem();
        return str == null || "".equals(str.trim());
    }
}

Related

  1. dateCompleteOnlyFormat(JTextField pJTextField, KeyEvent e)
  2. doAction(JTextField textField)
  3. fieldSetErrorVisual(final JTextField field)
  4. implyDisabled(final JCheckBox checked, final boolean checkedState, final JTextField changed)
  5. isActiveComponents(JTextField... textFields)
  6. isInHighlight(MouseEvent e, JTextField label, Highlighter h)
  7. isJTextFieldNotEmpty(javax.swing.JTextField field)
  8. isTelpValid(JTextField field)
  9. IsTextFieldEmpty(javax.swing.JTextField tf)