Java JComboBox isCbEquals(JComboBox cb, String str)

Here you can find the source of isCbEquals(JComboBox cb, String str)

Description

is Cb Equals

License

Open Source License

Declaration

public static boolean isCbEquals(JComboBox cb, String str) 

Method Source Code

//package com.java2s;
/*//from  www  .j av a 2s  .c  o m
 * SbApp: Open Source software for novelists and authors.
 * Original idea 2008 - 2012 Martin Mustun
 * Copyrigth (C) Favdb
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 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.
 */

import javax.swing.JComboBox;

public class Main {
    public static boolean isCbEquals(JComboBox cb, String str) {
        if (cb.getSelectedIndex() == -1) {
            if (str.equals("")) {
                return (true);
            }
        } else {
            if (str.equals("")) {
                return (false);
            }
            if (cb.getSelectedItem().equals(str)) {
                return (true);
            }
        }
        return (false);
    }
}

Related

  1. getOnlyComboBox(Container owner)
  2. getPrinterJComboBox()
  3. getScrollBarWidth(JComboBox comboBox, JScrollPane scrollPane)
  4. initCombo(JComboBox combo)
  5. inputComboBox(JComboBox cbx, String[] str)
  6. isComboBoxButton(AbstractButton button)
  7. isEmptyStr(javax.swing.JComboBox input)
  8. isJComboBoxNotEmpty(javax.swing.JComboBox combo)
  9. largeThan(javax.swing.JComboBox input, double x)