Java examples for Swing:JComboBox
Returns the currently selected Swing combobox value.
//package com.java2s; import javax.swing.JComboBox; public class Main { /**//from w w w . j a va 2 s. co m * Returns the currently selected combobox value. If there * is no value, it return the empty string. */ public static String getComboBoxValue(JComboBox comboBox) { if (comboBox.getSelectedItem() != null) { return comboBox.getSelectedItem().toString(); } else { return ""; } } }