Java JComboBox isEmptyStr(javax.swing.JComboBox input)

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

Description

Check if the JComboBox selection is empty

License

Open Source License

Parameter

Parameter Description
input the JComboBox object

Return

true or false

Declaration

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

Method Source Code

//package com.java2s;
/*//from   www  . j av a 2s .  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
 *   ================
 *
 */

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. getScrollBarWidth(JComboBox comboBox, JScrollPane scrollPane)
  2. initCombo(JComboBox combo)
  3. inputComboBox(JComboBox cbx, String[] str)
  4. isCbEquals(JComboBox cb, String str)
  5. isComboBoxButton(AbstractButton button)
  6. isJComboBoxNotEmpty(javax.swing.JComboBox combo)
  7. largeThan(javax.swing.JComboBox input, double x)
  8. loadComboBox(JComboBox combo, List list)
  9. loadEnum(JComboBox combo, Class c, boolean removeAll)